mirror of
https://github.com/status-im/realm-js.git
synced 2025-01-11 14:54:33 +00:00
Don't bother special-casing one-byte strings as they're more complicated than it seemed
This commit is contained in:
parent
1838f1f932
commit
3c45c8a750
@ -48,16 +48,9 @@ inline String<node::Types>::String(const v8::Local<v8::String> &s) {
|
||||
if (s.IsEmpty() || s->Length() == 0) {
|
||||
return;
|
||||
}
|
||||
if (s->IsOneByte()) {
|
||||
m_str.resize(s->Length());
|
||||
}
|
||||
else {
|
||||
// Length is in UCS-2 code units, which can take up to 3 bytes each to encode
|
||||
m_str.resize(3 * s->Length());
|
||||
}
|
||||
m_str.resize(s->Utf8Length());
|
||||
const int flags = v8::String::NO_NULL_TERMINATION | v8::String::REPLACE_INVALID_UTF8;
|
||||
auto length = s->WriteUtf8(&m_str[0], m_str.size(), 0, flags);
|
||||
m_str.resize(length);
|
||||
s->WriteUtf8(&m_str[0], m_str.size(), 0, flags);
|
||||
}
|
||||
|
||||
} // js
|
||||
|
Loading…
x
Reference in New Issue
Block a user