While the stumpless_prival_from_string function works, it currently allocates and later frees heap memory for temporary storage of strings during parsing. Now that #385 and #383 have been implemented, this function should be refactored so that it uses the new _from_buffer functions for facility and enum parsing to avoid heap memory allocations.
General Approach
There are a few details left out of the following approach, for you to fill in as you encounter them. If you find you need help, please ask here or on the project gitter and someone can help you get past the stumbling block.
Review the documentation for stumpless_get_facility_enum_from_buffer and stumpless_get_severity_enum_from_buffer so that you understand how they work, and then understand how stumpless_prival_from_string in src/prival.c currently works. This is the function you will be reworking.
Before you make any changes, make sure that you can run the performance tests, specifically the PrivalFromString benchmark. Make sure that you can collect performance both before and after you implement your change. You should see CPU cycles and memory allocated decrease as a result - if you do not, review your implementation and find out why. You can find details on running the performance benchmarks in stumpless in the docs/benchmark.md documentation.
Once you have this, make your changes and make sure that performance improves as expected! The test suites should continue to pass and coverage should not decrease as a result of your changes - you may need to add more tests for the refactored function to test/function/prival.cpp improve coverage depending on your implementation.
While the
stumpless_prival_from_string
function works, it currently allocates and later frees heap memory for temporary storage of strings during parsing. Now that #385 and #383 have been implemented, this function should be refactored so that it uses the new_from_buffer
functions for facility and enum parsing to avoid heap memory allocations.General Approach
There are a few details left out of the following approach, for you to fill in as you encounter them. If you find you need help, please ask here or on the project gitter and someone can help you get past the stumbling block.
Review the documentation for
stumpless_get_facility_enum_from_buffer
andstumpless_get_severity_enum_from_buffer
so that you understand how they work, and then understand howstumpless_prival_from_string
insrc/prival.c
currently works. This is the function you will be reworking.Before you make any changes, make sure that you can run the performance tests, specifically the
PrivalFromString
benchmark. Make sure that you can collect performance both before and after you implement your change. You should see CPU cycles and memory allocated decrease as a result - if you do not, review your implementation and find out why. You can find details on running the performance benchmarks in stumpless in the docs/benchmark.md documentation.Once you have this, make your changes and make sure that performance improves as expected! The test suites should continue to pass and coverage should not decrease as a result of your changes - you may need to add more tests for the refactored function to
test/function/prival.cpp
improve coverage depending on your implementation.