mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2025-02-26 07:16:57 +00:00
!7908 Optimize BuiltinsGlobal::Decode when string is tree string
Merge pull request !7908 from chenjingxiang/opt_decodeuri_br
This commit is contained in:
commit
f242284f87
@ -458,6 +458,10 @@ JSTaggedValue BuiltinsGlobal::Decode(JSThread *thread, const JSHandle<EcmaString
|
||||
// 2. Let R be the empty String.
|
||||
ObjectFactory *factory = thread->GetEcmaVM()->GetFactory();
|
||||
std::u16string resStr;
|
||||
JSHandle<EcmaString> string = str;
|
||||
if (EcmaStringAccessor(str).IsTreeString()) {
|
||||
string = JSHandle<EcmaString>(thread, EcmaStringAccessor::Flatten(thread->GetEcmaVM(), str));
|
||||
}
|
||||
|
||||
// 3. Let k be 0.
|
||||
// 4. Repeat
|
||||
@ -483,7 +487,7 @@ JSTaggedValue BuiltinsGlobal::Decode(JSThread *thread, const JSHandle<EcmaString
|
||||
// a. Let S be the String containing only the code unit C.
|
||||
// 3. Else C is in reservedSet,
|
||||
// a. Let S be the substring of string from index start to index k inclusive.
|
||||
uint16_t cc = EcmaStringAccessor(str).Get(k);
|
||||
uint16_t cc = EcmaStringAccessor(string).Get(k);
|
||||
std::u16string sStr;
|
||||
if (cc != '%') {
|
||||
if (cc == 0 && strLen == 1) {
|
||||
@ -492,7 +496,7 @@ JSTaggedValue BuiltinsGlobal::Decode(JSThread *thread, const JSHandle<EcmaString
|
||||
}
|
||||
sStr = StringHelper::Utf16ToU16String(&cc, 1);
|
||||
} else {
|
||||
DecodePercentEncoding(thread, str, k, IsInURISet, strLen, sStr);
|
||||
DecodePercentEncoding(thread, string, k, IsInURISet, strLen, sStr);
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
}
|
||||
resStr.append(sStr);
|
||||
|
@ -80,3 +80,9 @@ print(encodeURIComponent(uri11));
|
||||
print(encodeURIComponent(uri2));
|
||||
print(encodeURIComponent(uri3));
|
||||
print(encodeURIComponent(uri4));
|
||||
|
||||
print(decodeURIComponent(uri0));
|
||||
print(decodeURIComponent(uri11));
|
||||
print(decodeURIComponent(uri2));
|
||||
print(decodeURIComponent(uri3));
|
||||
print(decodeURIComponent(uri4));
|
@ -24,3 +24,8 @@ https%3A%2F%2Fwww.runoob.com%2Fmy%20test.php%3Fname%3Dst%C3%A5le%26car%3Dsaab%2F
|
||||
https%3A%2F%2Fwww.runoob.com%2Fmy%20test.php%3Fname%3Dst%C3%A5le%26car%3Dsaab%2F2389018203
|
||||
https%3A%2F%2Fwww.runoob.com%2Fmy%20test.php%3Fname%3Dst%C3%A5le%26car%3Dsaab%2Fjfdlskafasfd%2Fjd2931dsafdsa
|
||||
https%3A%2F%2Fwww.runoob.com%2Fmy%20test.php%3Fname%3Dst%C3%A5le%26car%3Dsaab%2Fjfdlskafasfd%2Fjd2931dsafdsa%2Fjd2931wjeiojfwre
|
||||
https://www.runoob.com/my test.php?name=ståle&car=saab
|
||||
https://www.runoob.com/my test.php?name=ståle&car=saab/jfdlskafasfd
|
||||
https://www.runoob.com/my test.php?name=ståle&car=saab/2389018203
|
||||
https://www.runoob.com/my test.php?name=ståle&car=saab/jfdlskafasfd/jd2931dsafdsa
|
||||
https://www.runoob.com/my test.php?name=ståle&car=saab/jfdlskafasfd/jd2931dsafdsa/jd2931wjeiojfwre
|
||||
|
Loading…
x
Reference in New Issue
Block a user