Bug 1817767 - Use CopyChars for rope atomization cache. r=jandem

Differential Revision: https://phabricator.services.mozilla.com/D170793
This commit is contained in:
Ted Campbell 2023-02-24 15:58:35 +00:00
Родитель c3b24d81c7
Коммит 596b90cea8
1 изменённых файлов: 3 добавлений и 6 удалений

Просмотреть файл

@ -744,18 +744,15 @@ JSAtom* js::AtomizeString(JSContext* cx, JSString* str) {
JS::Latin1Char flattenRope[StringToAtomCache::MinStringLength];
mozilla::Maybe<StringToAtomCache::AtomTableKey> key;
size_t length = str->length();
if (!str->isLinear() && length < StringToAtomCache::MinStringLength &&
if (str->isRope() && length < StringToAtomCache::MinStringLength &&
str->hasLatin1Chars()) {
StringSegmentRange<StringToAtomCache::MinStringLength> iter(cx);
if (iter.init(str)) {
JS::AutoCheckCannotGC nogc;
size_t index = 0;
do {
const JSLinearString* s = iter.front();
size_t len = s->length();
const JS::Latin1Char* latinChars = s->latin1Chars(nogc);
memcpy(flattenRope + index, latinChars, len);
index += len;
CopyChars(flattenRope + index, *s);
index += s->length();
} while (iter.popFront() && !iter.empty());
if (JSAtom* atom = cx->caches().stringToAtomCache.lookupWithRopeChars(