stacktrace icon indicating copy to clipboard operation
stacktrace copied to clipboard

[Windows] Can save a `strlen` call knowing there's exactly one zero

Open AlexGuteniev opened this issue 3 years ago • 0 comments

Not sure if it is really needed, as perf gain and simplification are both very small.

Referring to this: https://github.com/boostorg/stacktrace/blob/75b7986f9799184ecd679d86273532cb54e6a0dc/include/boost/stacktrace/detail/frame_msvc.ipp#L222-L234

According to the updated IDebugSymbols::GetNameByOffset documentation, sizes will include the space for exactly one null terminator:

This size includes the space for the '\0' terminating character.

So the assignment in the else branch can be like:

result.assign(name, size - 1);

and trim_right_zeroes can be avoided by resizing string as result.resize(size - 1) prior the second call.

Ditto for GetLineByOffset below.

AlexGuteniev avatar Feb 09 '22 13:02 AlexGuteniev