From 71a452f8ce12e31cc4e0d8c7878567b0c7fc63c2 Mon Sep 17 00:00:00 2001 From: tsepez Date: Fri, 13 May 2016 17:51:27 -0700 Subject: Make CFX_ByteString(const CFX_ByteStringC&) explicit. Add missing helper function to CFX_ByteTextBuf to avoid the anti-pattern CFX_ByteString(sBuf.AsStringC()), using the name "Make" to indicate there's an allocation going on in this case. Change some method arguments to take pre-existing ByteStrings where possible. Review-Url: https://codereview.chromium.org/1977093002 --- core/fxge/ge/fx_ge_fontmap.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'core/fxge/ge/fx_ge_fontmap.cpp') diff --git a/core/fxge/ge/fx_ge_fontmap.cpp b/core/fxge/ge/fx_ge_fontmap.cpp index 8524660043..e8af2dce53 100644 --- a/core/fxge/ge/fx_ge_fontmap.cpp +++ b/core/fxge/ge/fx_ge_fontmap.cpp @@ -317,7 +317,7 @@ CFX_ByteString GetFontFamily(CFX_ByteString fontName, int nStyle) { CFX_ByteString ParseStyle(const FX_CHAR* pStyle, int iLen, int iIndex) { CFX_ByteTextBuf buf; if (!iLen || iLen <= iIndex) { - return buf.AsStringC(); + return buf.MakeString(); } while (iIndex < iLen) { if (pStyle[iIndex] == ',') { @@ -326,7 +326,7 @@ CFX_ByteString ParseStyle(const FX_CHAR* pStyle, int iLen, int iIndex) { buf.AppendChar(pStyle[iIndex]); ++iIndex; } - return buf.AsStringC(); + return buf.MakeString(); } int32_t GetStyleType(const CFX_ByteString& bsStyle, FX_BOOL bRevert) { @@ -688,7 +688,7 @@ static CFX_ByteString GetStringFromTable(const uint8_t* string_ptr, if (string_ptr_length < static_cast(offset + length)) { return CFX_ByteString(); } - return CFX_ByteStringC(string_ptr + offset, length); + return CFX_ByteString(string_ptr + offset, length); } CFX_ByteString GetNameFromTT(const uint8_t* name_table, @@ -1368,12 +1368,15 @@ CFX_FolderFontInfo::~CFX_FolderFontInfo() { delete pair.second; } } + void CFX_FolderFontInfo::AddPath(const CFX_ByteStringC& path) { - m_PathList.push_back(path); + m_PathList.push_back(CFX_ByteString(path)); } + void CFX_FolderFontInfo::Release() { delete this; } + FX_BOOL CFX_FolderFontInfo::EnumFontList(CFX_FontMapper* pMapper) { m_pMapper = pMapper; for (const auto& path : m_PathList) -- cgit v1.2.3