[Webkit-unassigned] [Bug 92872] New: A smart util class that grabs latin1 string from a WTF::String
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Wed Aug 1 07:30:15 PDT 2012
https://bugs.webkit.org/show_bug.cgi?id=92872
Summary: A smart util class that grabs latin1 string from a
WTF::String
Product: WebKit
Version: 528+ (Nightly build)
Platform: Unspecified
OS/Version: Unspecified
Status: NEW
Severity: Normal
Priority: P2
Component: Text
AssignedTo: webkit-unassigned at lists.webkit.org
ReportedBy: yoli at rim.com
In many cases, we know a WTF::String is 99% a 8bit string internally, but to avoid crash in the 1%, we have to do this for best performance:
str.is8Bit() ? str.characters8() : static_cast<LChar>(str.latin1.data())
Not convenient at all. And most developer will just use str.latin1.data() when they need to get a const char*.
So how about adding a util class that either has a valid CString object or uses String's 8bit data?
class Latin1StringHolder {
public:
explicit Latin1StringHolder (String string)
{
if (string.is8Bit())
m_string = string;
else
m_latin1 = string.latin1();
}
const LChar* data() const { return m_string.isNull() ? static_cast<LChar>(m_latin1.data()) : m_string.characters8; }
size_t length() const { return m_string.isNull() ? m_latin1.length() : m_string.lenght(); }
private:
CString m_latin1;
String m_string;
};
--
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the webkit-unassigned
mailing list