mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-10-07 16:13:49 +00:00
add 'utf8Len' parameter for 'CanBeCompressed()'
Signed-off-by: zhaozhibo <zhaozhibo3@huawei.com>
This commit is contained in:
parent
55e79d9150
commit
6669d22e37
@ -246,9 +246,6 @@ bool EcmaString::CanBeCompressed(const uint8_t *utf8Data, uint32_t utf8Len)
|
||||
}
|
||||
bool isCompressed = true;
|
||||
uint32_t index = 0;
|
||||
if (utf8Len == UINT32_MAX) {
|
||||
utf8Len = strlen((const char *)utf8Data);
|
||||
}
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
|
||||
while (index < utf8Len) {
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
|
||||
|
@ -260,7 +260,7 @@ public:
|
||||
|
||||
static EcmaString *AllocStringObject(size_t length, bool compressed, const EcmaVM *vm);
|
||||
|
||||
static bool CanBeCompressed(const uint8_t *utf8Data, uint32_t utf8Len = UINT32_MAX);
|
||||
static bool CanBeCompressed(const uint8_t *utf8Data, uint32_t utf8Len);
|
||||
static bool CanBeCompressed(const uint16_t *utf16Data, uint32_t utf16Len);
|
||||
|
||||
private:
|
||||
|
@ -2065,21 +2065,24 @@ JSHandle<ClassInfoExtractor> ObjectFactory::NewClassInfoExtractor(JSMethod *ctor
|
||||
JSHandle<EcmaString> ObjectFactory::NewFromString(const CString &data)
|
||||
{
|
||||
auto utf8Data = reinterpret_cast<const uint8_t *>(data.c_str());
|
||||
bool canBeCompress = EcmaString::CanBeCompressed(utf8Data);
|
||||
uint32_t utf8Len = strlen(utf8Data);
|
||||
bool canBeCompress = EcmaString::CanBeCompressed(utf8Data, utf8Len);
|
||||
return GetStringFromStringTable(utf8Data, data.length(), canBeCompress);
|
||||
}
|
||||
|
||||
JSHandle<EcmaString> ObjectFactory::NewFromCanBeCompressString(const CString &data)
|
||||
{
|
||||
auto utf8Data = reinterpret_cast<const uint8_t *>(data.c_str());
|
||||
ASSERT(EcmaString::CanBeCompressed(utf8Data));
|
||||
uint32_t utf8Len = strlen(utf8Data);
|
||||
ASSERT(EcmaString::CanBeCompressed(utf8Data, utf8Len));
|
||||
return GetStringFromStringTable(utf8Data, data.length(), true);
|
||||
}
|
||||
|
||||
JSHandle<EcmaString> ObjectFactory::NewFromStdString(const std::string &data)
|
||||
{
|
||||
auto utf8Data = reinterpret_cast<const uint8_t *>(data.c_str());
|
||||
bool canBeCompress = EcmaString::CanBeCompressed(utf8Data);
|
||||
uint32_t utf8Len = strlen(utf8Data);
|
||||
bool canBeCompress = EcmaString::CanBeCompressed(utf8Data, utf8Len);
|
||||
return GetStringFromStringTable(utf8Data, data.size(), canBeCompress);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user