mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2025-02-25 23:08:22 +00:00
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:
parent
3bec1b9301
commit
199328eb91
@ -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);
|
||||
{
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user