Page MenuHome

BLF: Don't Print Empty Strings
ClosedPublic

Authored by Harley Acheson (harley) on Jul 16 2022, 2:29 AM.

Details

Summary

Optimize font drawing by skipping empty strings.


blf_font_draw_ex contains an early-out test that the passed str_len is not zero. Unfortunately str_len is the byte size of the string buffer, not the string length. We never send a zero-length buffer to the function but we do send empty strings to it all the time. I count at least 60 during startup alone.

This patch just adds a test for empty string to that early exit, which basically just avoids unnecessary calls to blf_batch_draw_begin and blf_batch_draw_end

Diff Detail

Repository
rB Blender

Event Timeline

Harley Acheson (harley) requested review of this revision.Jul 16 2022, 2:29 AM
Harley Acheson (harley) created this revision.
This revision is now accepted and ready to land.Jul 16 2022, 2:59 PM
This revision was automatically updated to reflect the committed changes.