зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
acc49289d6
Коммит
9ffa464dfb
|
@ -8564,7 +8564,7 @@ class MOZ_STACK_CLASS FileHelper final {
|
||||||
bool TokenizerIgnoreNothing(char16_t /* aChar */) { return false; }
|
bool TokenizerIgnoreNothing(char16_t /* aChar */) { return false; }
|
||||||
|
|
||||||
nsresult DeserializeStructuredCloneFile(const FileManager& aFileManager,
|
nsresult DeserializeStructuredCloneFile(const FileManager& aFileManager,
|
||||||
const nsString& aText,
|
const nsDependentSubstring& aText,
|
||||||
StructuredCloneFile* aFile) {
|
StructuredCloneFile* aFile) {
|
||||||
MOZ_ASSERT(!aText.IsEmpty());
|
MOZ_ASSERT(!aText.IsEmpty());
|
||||||
MOZ_ASSERT(aFile);
|
MOZ_ASSERT(aFile);
|
||||||
|
@ -8634,11 +8634,10 @@ nsresult DeserializeStructuredCloneFiles(
|
||||||
nsCharSeparatedTokenizerTemplate<TokenizerIgnoreNothing> tokenizer(aText,
|
nsCharSeparatedTokenizerTemplate<TokenizerIgnoreNothing> tokenizer(aText,
|
||||||
' ');
|
' ');
|
||||||
|
|
||||||
nsAutoString token;
|
|
||||||
nsresult rv;
|
nsresult rv;
|
||||||
|
|
||||||
while (tokenizer.hasMoreTokens()) {
|
while (tokenizer.hasMoreTokens()) {
|
||||||
token = tokenizer.nextToken();
|
const auto& token = tokenizer.nextToken();
|
||||||
MOZ_ASSERT(!token.IsEmpty());
|
MOZ_ASSERT(!token.IsEmpty());
|
||||||
|
|
||||||
auto* const file = aResult.EmplaceBack(StructuredCloneFile::eBlob);
|
auto* const file = aResult.EmplaceBack(StructuredCloneFile::eBlob);
|
||||||
|
|
|
@ -36,13 +36,13 @@ bool IsValidKeyPathString(const nsAString& aKeyPath) {
|
||||||
KeyPathTokenizer tokenizer(aKeyPath, '.');
|
KeyPathTokenizer tokenizer(aKeyPath, '.');
|
||||||
|
|
||||||
while (tokenizer.hasMoreTokens()) {
|
while (tokenizer.hasMoreTokens()) {
|
||||||
nsString token(tokenizer.nextToken());
|
const auto& token = tokenizer.nextToken();
|
||||||
|
|
||||||
if (!token.Length()) {
|
if (!token.Length()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!JS_IsIdentifier(token.get(), token.Length())) {
|
if (!JS_IsIdentifier(token.Data(), token.Length())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ nsresult GetJSValFromKeyPathString(
|
||||||
JS::Rooted<JSObject*> obj(aCx);
|
JS::Rooted<JSObject*> obj(aCx);
|
||||||
|
|
||||||
while (tokenizer.hasMoreTokens()) {
|
while (tokenizer.hasMoreTokens()) {
|
||||||
const nsDependentSubstring& token = tokenizer.nextToken();
|
const auto& token = tokenizer.nextToken();
|
||||||
|
|
||||||
NS_ASSERTION(!token.IsEmpty(), "Should be a valid keypath");
|
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
|
// There is a trailing comma, indicating the original KeyPath has
|
||||||
// a trailing empty string, i.e. [..., '']. We should append this
|
// a trailing empty string, i.e. [..., '']. We should append this
|
||||||
// empty string.
|
// empty string.
|
||||||
keyPath.mStrings.AppendElement(nsString{});
|
keyPath.mStrings.EmplaceBack();
|
||||||
}
|
}
|
||||||
|
|
||||||
return keyPath;
|
return keyPath;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче