Skip to content

Commit

Permalink
Remove another unnecessary buffer copy.
Browse files Browse the repository at this point in the history
Also, use `hxs_utf8()` for consistency.
  • Loading branch information
player-03 committed Jan 31, 2024
1 parent 590be2b commit 7c50f6e
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions project/src/ExternalInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,7 @@ namespace lime {

#ifdef LIME_FREETYPE
Font *font = (Font*)val_data (fontHandle);
return font->GetGlyphIndex (character.c_str ());
return font->GetGlyphIndex (hxs_utf8 (character, nullptr));
#else
return -1;
#endif
Expand All @@ -1222,10 +1222,7 @@ namespace lime {

#ifdef LIME_FREETYPE
Font *font = (Font*)val_data (fontHandle);
const std::string str (hxs_utf8 (characters, nullptr));
const std::unique_ptr<char[]> buff (new char[str.size() + 1]);
std::memcpy (buff.get (), str.c_str (), str.size () + 1);
return (value)font->GetGlyphIndices (true, buff.get ());
return (value)font->GetGlyphIndices (true, hxs_utf8 (characters, nullptr));
#else
return alloc_null ();
#endif
Expand Down

0 comments on commit 7c50f6e

Please sign in to comment.