mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-10-06 23:54:03 +00:00
Remove unused method
The string join is done by BuiltinsArray::Join, this method is unused, remove it to avoid misleading Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/IANRSP Signed-off-by: ZhouGuangyuan <zhouguangyuan1@huawei.com> Change-Id: I689017374ada679fcd4c163c8181619e8dcdec39
This commit is contained in:
parent
d20d3c2103
commit
797a742853
@ -571,97 +571,6 @@ JSTaggedValue JSStableArray::Join(JSThread *thread, JSHandle<JSArray> receiver,
|
||||
return JSTaggedValue(newString);
|
||||
}
|
||||
|
||||
JSTaggedValue JSStableArray::Join(JSHandle<JSSharedArray> receiver, EcmaRuntimeCallInfo *argv)
|
||||
{
|
||||
JSThread *thread = argv->GetThread();
|
||||
uint32_t length = receiver->GetArrayLength();
|
||||
JSHandle<JSTaggedValue> sepHandle = base::BuiltinsBase::GetCallArg(argv, 0);
|
||||
int sep = ',';
|
||||
uint32_t sepLength = 1;
|
||||
JSHandle<EcmaString> sepStringHandle;
|
||||
auto context = thread->GetCurrentEcmaContext();
|
||||
JSHandle<JSTaggedValue> receiverValue = JSHandle<JSTaggedValue>::Cast(receiver);
|
||||
if (!sepHandle->IsUndefined()) {
|
||||
if (sepHandle->IsString()) {
|
||||
sepStringHandle = JSHandle<EcmaString>::Cast(sepHandle);
|
||||
} else {
|
||||
sepStringHandle = JSTaggedValue::ToString(thread, sepHandle);
|
||||
RETURN_EXCEPTION_AND_POP_JOINSTACK(thread, receiverValue);
|
||||
}
|
||||
SetSepValue(sepStringHandle, sep, sepLength);
|
||||
}
|
||||
if (length == 0) {
|
||||
const GlobalEnvConstants *globalConst = thread->GlobalConstants();
|
||||
context->JoinStackPopFastPath(receiverValue);
|
||||
return globalConst->GetEmptyString();
|
||||
}
|
||||
JSHandle<JSObject> obj(thread, receiverValue.GetTaggedValue());
|
||||
size_t allocateLength = 0;
|
||||
bool isOneByte = (sep != JSStableArray::SeparatorFlag::MINUS_ONE) || EcmaStringAccessor(sepStringHandle).IsUtf8();
|
||||
JSMutableHandle<JSTaggedValue> elementHandle(thread, JSTaggedValue::Undefined());
|
||||
const GlobalEnvConstants *globalConst = thread->GlobalConstants();
|
||||
uint32_t elementsLength = ElementAccessor::GetElementsLength(obj);
|
||||
uint32_t len = elementsLength > length ? length : elementsLength;
|
||||
if (elementsLength == 0 && length != 0) {
|
||||
len = length;
|
||||
}
|
||||
if (len <= 1) {
|
||||
// sep unused, set isOneByte to default(true)
|
||||
isOneByte = true;
|
||||
}
|
||||
CVector<JSHandle<EcmaString>> vec;
|
||||
vec.reserve(len);
|
||||
for (uint32_t k = 0; k < len; k++) {
|
||||
JSTaggedValue element = JSTaggedValue::Undefined();
|
||||
if (k < elementsLength) {
|
||||
element = ElementAccessor::Get(obj, k);
|
||||
}
|
||||
if (!element.IsUndefinedOrNull() && !element.IsHole()) {
|
||||
if (!element.IsString()) {
|
||||
elementHandle.Update(element);
|
||||
JSHandle<EcmaString> strElement = JSTaggedValue::ToString(thread, elementHandle);
|
||||
RETURN_EXCEPTION_AND_POP_JOINSTACK(thread, receiverValue);
|
||||
element = strElement.GetTaggedValue();
|
||||
}
|
||||
auto nextStr = EcmaString::Cast(element.GetTaggedObject());
|
||||
vec.emplace_back(thread, nextStr);
|
||||
isOneByte = EcmaStringAccessor(nextStr).IsUtf8() ? isOneByte : false;
|
||||
allocateLength += EcmaStringAccessor(nextStr).GetLength();
|
||||
} else {
|
||||
vec.emplace_back(globalConst->GetHandledEmptyString());
|
||||
}
|
||||
}
|
||||
if (len > 0) {
|
||||
allocateLength += sepLength * (len - 1);
|
||||
}
|
||||
if (WorthUseTreeString(sep, allocateLength, len)) {
|
||||
return JoinUseTreeString(thread, receiverValue, sepStringHandle, sep, vec);
|
||||
}
|
||||
auto newString = EcmaStringAccessor::CreateLineString(thread->GetEcmaVM(), allocateLength, isOneByte);
|
||||
int current = 0;
|
||||
DISALLOW_GARBAGE_COLLECTION;
|
||||
for (uint32_t k = 0; k < len; k++) {
|
||||
if (k > 0) {
|
||||
if (sep >= 0) {
|
||||
EcmaStringAccessor(newString).Set(current, static_cast<uint16_t>(sep));
|
||||
} else if (sep != JSStableArray::SeparatorFlag::MINUS_TWO) {
|
||||
EcmaStringAccessor::ReadData(newString, *sepStringHandle, current,
|
||||
allocateLength - static_cast<uint32_t>(current), sepLength);
|
||||
}
|
||||
current += static_cast<int>(sepLength);
|
||||
}
|
||||
JSHandle<EcmaString> nextStr = vec[k];
|
||||
int nextLength = static_cast<int>(EcmaStringAccessor(nextStr).GetLength());
|
||||
EcmaStringAccessor::ReadData(newString, *nextStr, current,
|
||||
allocateLength - static_cast<uint32_t>(current), nextLength);
|
||||
current += nextLength;
|
||||
}
|
||||
ASSERT_PRINT(
|
||||
isOneByte == EcmaStringAccessor::CanBeCompressed(newString), "isOneByte does not match the real value!");
|
||||
context->JoinStackPopFastPath(receiverValue);
|
||||
return JSTaggedValue(newString);
|
||||
}
|
||||
|
||||
JSTaggedValue JSStableArray::HandleFindIndexOfStable(JSThread *thread, JSHandle<JSObject> thisObjHandle,
|
||||
JSHandle<JSTaggedValue> callbackFnHandle,
|
||||
JSHandle<JSTaggedValue> thisArgHandle, uint32_t &k)
|
||||
|
@ -41,7 +41,6 @@ public:
|
||||
static JSTaggedValue Shift(JSHandle<JSSharedArray> receiver, EcmaRuntimeCallInfo *argv);
|
||||
static JSTaggedValue Join(JSThread *thread, JSHandle<JSArray> receiver,
|
||||
JSHandle<EcmaString> sepStringHandle, int64_t length);
|
||||
static JSTaggedValue Join(JSHandle<JSSharedArray> receiver, EcmaRuntimeCallInfo *argv);
|
||||
static JSTaggedValue HandleFindIndexOfStable(JSThread *thread, JSHandle<JSObject> thisObjHandle,
|
||||
JSHandle<JSTaggedValue> callbackFnHandle,
|
||||
JSHandle<JSTaggedValue> thisArgHandle, uint32_t &k);
|
||||
|
Loading…
Reference in New Issue
Block a user