Bug 1651390 - Part 1: Copy comments from NewString[DontDeflate]. r=sfink

Copy the comments to the `NewString<allowGC>` alternatives before removing
the functions in part 2.

Differential Revision: https://phabricator.services.mozilla.com/D82732
This commit is contained in:
André Bargull 2020-07-09 18:12:31 +00:00
Родитель 444700f8d1
Коммит f36ea50e8b
1 изменённых файлов: 4 добавлений и 0 удалений

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

@ -1680,6 +1680,8 @@ JSLinearString* js::NewStringDontDeflate(
} }
if (JSInlineString::lengthFits<CharT>(length)) { if (JSInlineString::lengthFits<CharT>(length)) {
// |chars.get()| is safe because 1) |NewInlineString| necessarily *copies*,
// and 2) |chars| frees its contents only when this function returns.
return NewInlineString<allowGC>( return NewInlineString<allowGC>(
cx, mozilla::Range<const CharT>(chars.get(), length), heap); cx, mozilla::Range<const CharT>(chars.get(), length), heap);
} }
@ -1710,6 +1712,8 @@ JSLinearString* js::NewString(JSContext* cx,
size_t length, gc::InitialHeap heap) { size_t length, gc::InitialHeap heap) {
if constexpr (std::is_same_v<CharT, char16_t>) { if constexpr (std::is_same_v<CharT, char16_t>) {
if (CanStoreCharsAsLatin1(chars.get(), length)) { if (CanStoreCharsAsLatin1(chars.get(), length)) {
// Deflating copies from |chars.get()| and lets |chars| be freed on
// return.
return NewStringDeflated<allowGC>(cx, chars.get(), length, heap); return NewStringDeflated<allowGC>(cx, chars.get(), length, heap);
} }
} }