Bug 1543455 - Make JS::{Compile,Evaluate}Utf8Path operate directly on UTF-8 data without first inflating it. r=arai

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

--HG--
extra : rebase_source : 5263ded87c29973c22852e64d2fcca937968b083
This commit is contained in:
Jeff Walden 2019-04-09 14:35:02 -07:00
parent a3171569ec
commit d201fc4b29

View File

@ -149,7 +149,7 @@ JSScript* JS::CompileUtf8Path(JSContext* cx,
CompileOptions options(cx, optionsArg);
options.setFileAndLine(filename, 1);
return CompileUtf8File(cx, options, file.fp());
return CompileUtf8FileDontInflate(cx, options, file.fp());
}
JSScript* JS::CompileForNonSyntacticScope(
@ -583,15 +583,9 @@ JS_PUBLIC_API bool JS::EvaluateUtf8Path(
auto contents = reinterpret_cast<const char*>(buffer.begin());
size_t length = buffer.length();
auto chars = UniqueTwoByteChars(
UTF8CharsToNewTwoByteCharsZ(cx, UTF8Chars(contents, length), &length)
.get());
if (!chars) {
return false;
}
SourceText<char16_t> srcBuf;
if (!srcBuf.init(cx, std::move(chars), length)) {
JS::SourceText<Utf8Unit> srcBuf;
if (!srcBuf.init(cx, contents, length, JS::SourceOwnership::Borrowed)) {
return false;
}