From f21720dc79127b61b5b299b9b597d499c20814b0 Mon Sep 17 00:00:00 2001 From: Zach Nelson Date: Mon, 16 Feb 2026 15:07:08 -0600 Subject: [PATCH] perf: Skip constructing unnecessary std::string (#932) ## Summary **What is the goal of this PR?** Skip constructing a `std::string` just to get the underlying `c_str()` buffer, when a string literal gives the same end result. --- ### AI Usage While CrossPoint doesn't have restrictions on AI tools in contributing, please be transparent about their usage as it helps set the right context for reviewers. Did you use AI tools to help write this code? _**NO**_ --- lib/Epub/Epub/blocks/TextBlock.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Epub/Epub/blocks/TextBlock.cpp b/lib/Epub/Epub/blocks/TextBlock.cpp index cda885c5..471c3af8 100644 --- a/lib/Epub/Epub/blocks/TextBlock.cpp +++ b/lib/Epub/Epub/blocks/TextBlock.cpp @@ -30,7 +30,7 @@ void TextBlock::render(const GfxRenderer& renderer, const int fontId, const int if (w.size() >= 3 && static_cast(w[0]) == 0xE2 && static_cast(w[1]) == 0x80 && static_cast(w[2]) == 0x83) { const char* visiblePtr = w.c_str() + 3; - const int prefixWidth = renderer.getTextAdvanceX(fontId, std::string("\xe2\x80\x83").c_str()); + const int prefixWidth = renderer.getTextAdvanceX(fontId, "\xe2\x80\x83"); const int visibleWidth = renderer.getTextWidth(fontId, visiblePtr, currentStyle); startX = wordX + prefixWidth; underlineWidth = visibleWidth;