summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorMartok <martok@martoks-place.de>2022-07-01 12:27:03 +0200
committerMartok <martok@martoks-place.de>2022-07-01 20:21:54 +0200
commit16b11770a11adea8f0a9f6d2c85cbe46c794895e (patch)
tree338d6aa6b7a850090aada46fc31f26064582e257 /js
parent7277d7c6d744f60d4f82bfdf4d3068425aa00a2d (diff)
downloaduxp-16b11770a11adea8f0a9f6d2c85cbe46c794895e.tar.gz
Issue #1952 - m-c 1380962/1: Merge append calls when assembling the source string for native functions
Diffstat (limited to 'js')
-rw-r--r--js/src/jsfun.cpp16
1 files changed, 4 insertions, 12 deletions
diff --git a/js/src/jsfun.cpp b/js/src/jsfun.cpp
index c409a0f29b..e71a495028 100644
--- a/js/src/jsfun.cpp
+++ b/js/src/jsfun.cpp
@@ -990,7 +990,7 @@ js::FunctionToString(JSContext* cx, HandleFunction fun, bool prettyPrint)
// If we're not in pretty mode, put parentheses around lambda functions
// so that eval returns lambda, not function statement.
if (haveSource && !prettyPrint && funIsNonArrowLambda) {
- if (!out.append("("))
+ if (!out.append('('))
return nullptr;
}
@@ -1038,7 +1038,7 @@ js::FunctionToString(JSContext* cx, HandleFunction fun, bool prettyPrint)
return nullptr;
if (!prettyPrint && funIsNonArrowLambda) {
- if (!out.append(")"))
+ if (!out.append(')'))
return nullptr;
}
} else if (fun->isInterpreted() &&
@@ -1056,22 +1056,14 @@ js::FunctionToString(JSContext* cx, HandleFunction fun, bool prettyPrint)
!script->scriptSource()->sourceRetrievable() ||
fun->compartment()->behaviors().discardSource());
if (!AppendPrelude() ||
- !out.append("() {\n ") ||
- !out.append("[sourceless code]") ||
- !out.append("\n}"))
+ !out.append("() {\n [sourceless code]\n}"))
{
return nullptr;
}
} else {
if (!AppendPrelude() ||
- !out.append("() {\n "))
- return nullptr;
-
- if (!out.append("[native code]"))
- return nullptr;
-
- if (!out.append("\n}"))
+ !out.append("() {\n [native code]\n}"))
return nullptr;
}
return out.finishString();