Minor optimization and cleanup for PositionCodec
ClosedPublic

Authored by bruns on Mon, Dec 3, 2:55 PM.

Details

Summary

Both getVarint32Ptr and getVarint32PtrFallback return nullptr when
p >= limit. Avoid the call to getVarint32PtrFallback and immediately
return from getVarint32.

As it is safe to call getVarint32 with p >= limit, skip the extra check in
each getDifferentialVarInt32 loop iteration, speeds up decoding results
for the 3 benchmark cases by ~10%.

Remove unnecessary reinterpret_cast<char*>(p), p is a char*.

Test Plan

positioncodecbenchmark
ctest

Diff Detail

Repository
R293 Baloo
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
bruns created this revision.Mon, Dec 3, 2:55 PM
Restricted Application added projects: Frameworks, Baloo. · View Herald TranscriptMon, Dec 3, 2:55 PM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
bruns requested review of this revision.Mon, Dec 3, 2:55 PM
ngraham accepted this revision.Mon, Dec 3, 8:46 PM
This revision is now accepted and ready to land.Mon, Dec 3, 8:46 PM
This revision was automatically updated to reflect the committed changes.