Compress singlecode for ldStringByIndex

Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IACQOS?from=project-issue
Signed-off-by: 刘智杰 <liuzhijie9@huawei.com>
Change-Id: I59be68a5dfc2e9bb5ecd06b2c9b631b86d8b1e5c
This commit is contained in:
刘智杰 2024-07-11 21:41:17 +08:00
parent 3bec1b9301
commit 199328eb91
2 changed files with 40 additions and 1 deletions

View File

@ -1190,7 +1190,9 @@ GateRef BuiltinsStringStubBuilder::CreateStringBySingleCharCode(GateRef glue, Ga
BRANCH(canStoreAsUtf8, &utf8, &utf16);
Bind(&utf8);
{
newBuilder.AllocLineStringObject(&result, &afterNew, Int32(1), true);
GateRef singleCharTable = GetSingleCharTable(glue);
result = GetValueFromTaggedArray(singleCharTable, charCode);
Jump(&exit);
}
Bind(&utf16);
{

View File

@ -38,3 +38,40 @@ function testHolyArray() {
print(arrayTest[9] === undefined);
}
testHolyArray();
function testStringIndex() {
class A {
constructor() {
var gotoFn = {
0: {}
};
this.gotoFn = gotoFn;
}
search(string) {
var state = 0;
var results = [];
for (var i=0; i<string.length; i++) {
var l = string[i];
if (!(l in this.gotoFn[state])) {
continue;
}
state = this.gotoFn[state][l];
}
return results;
};
}
let words = ""
for (let i = 0; i < 100; i++) {
words += "should find keyword" + i + " at position " + i + "and"
}
let ac = new A();
for (let i = 0; i < 100; i++) {
ac.search(words)
}
}
testStringIndex();