From 590be2bbe6e33d832bc20e6b33c26221824b1b04 Mon Sep 17 00:00:00 2001 From: player-03 Date: Wed, 31 Jan 2024 13:46:09 -0500 Subject: [PATCH] Remove unnecessary string copy. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Casting `const char*` → `char*` is bad form, and we'd rather copy the string than do that. However, `GetGlyphIndex()` now takes a const, so neither workaround is needed. --- project/src/ExternalInterface.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/project/src/ExternalInterface.cpp b/project/src/ExternalInterface.cpp index 0f5503533..85987e569 100644 --- a/project/src/ExternalInterface.cpp +++ b/project/src/ExternalInterface.cpp @@ -1198,10 +1198,7 @@ namespace lime { #ifdef LIME_FREETYPE Font *font = (Font*)val_data (fontHandle); - const std::string str (hxs_utf8 (character, nullptr)); - const std::unique_ptr buff (new char[str.size() + 1]); - std::memcpy (buff.get (), str.c_str (), str.size () + 1); - return font->GetGlyphIndex (buff.get ()); + return font->GetGlyphIndex (character.c_str ()); #else return -1; #endif