Bug 1596395 - Avoid copying of tokenizer token sub-strings. r=dom-workers-and-storage-reviewers,edenchuang

Differential Revision: https://phabricator.services.mozilla.com/D53013

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Simon Giesecke 2019-11-29 10:40:55 +00:00
Родитель acc49289d6
Коммит 9ffa464dfb
2 изменённых файлов: 6 добавлений и 7 удалений

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

@ -8564,7 +8564,7 @@ class MOZ_STACK_CLASS FileHelper final {
bool TokenizerIgnoreNothing(char16_t /* aChar */) { return false; }
nsresult DeserializeStructuredCloneFile(const FileManager& aFileManager,
const nsString& aText,
const nsDependentSubstring& aText,
StructuredCloneFile* aFile) {
MOZ_ASSERT(!aText.IsEmpty());
MOZ_ASSERT(aFile);
@ -8634,11 +8634,10 @@ nsresult DeserializeStructuredCloneFiles(
nsCharSeparatedTokenizerTemplate<TokenizerIgnoreNothing> tokenizer(aText,
' ');
nsAutoString token;
nsresult rv;
while (tokenizer.hasMoreTokens()) {
token = tokenizer.nextToken();
const auto& token = tokenizer.nextToken();
MOZ_ASSERT(!token.IsEmpty());
auto* const file = aResult.EmplaceBack(StructuredCloneFile::eBlob);

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

@ -36,13 +36,13 @@ bool IsValidKeyPathString(const nsAString& aKeyPath) {
KeyPathTokenizer tokenizer(aKeyPath, '.');
while (tokenizer.hasMoreTokens()) {
nsString token(tokenizer.nextToken());
const auto& token = tokenizer.nextToken();
if (!token.Length()) {
return false;
}
if (!JS_IsIdentifier(token.get(), token.Length())) {
if (!JS_IsIdentifier(token.Data(), token.Length())) {
return false;
}
}
@ -76,7 +76,7 @@ nsresult GetJSValFromKeyPathString(
JS::Rooted<JSObject*> obj(aCx);
while (tokenizer.hasMoreTokens()) {
const nsDependentSubstring& token = tokenizer.nextToken();
const auto& token = tokenizer.nextToken();
NS_ASSERTION(!token.IsEmpty(), "Should be a valid keypath");
@ -472,7 +472,7 @@ KeyPath KeyPath::DeserializeFromString(const nsAString& aString) {
// There is a trailing comma, indicating the original KeyPath has
// a trailing empty string, i.e. [..., '']. We should append this
// empty string.
keyPath.mStrings.AppendElement(nsString{});
keyPath.mStrings.EmplaceBack();
}
return keyPath;