mirror of
https://github.com/morluto/rea.git
synced 2026-11-19 13:12:26 +00:00
perf(go): batch literal text in quoted build settings (#12238)
This commit is contained in:
1 parent
fedf33eb59
commit
e36bcfec67
2 files changed
+12
-6
No files matched your search
+10
-4
@@ -38,10 +38,16 @@ const quoted = (input: string): { value: string; end: number } | null => {
|
||||
}
|
||||
if (character === "\n") return null;
|
||||
if (character !== "\\") {
|
||||
const point = input.codePointAt(index);
|
||||
if (point === undefined) return null;
|
||||
length += output.write(String.fromCodePoint(point), length, "utf8");
|
||||
index += point > 0xffff ? 2 : 1;
|
||||
const start = index;
|
||||
do {
|
||||
index += 1;
|
||||
} while (
|
||||
index < input.length &&
|
||||
input[index] !== '"' &&
|
||||
input[index] !== "\n" &&
|
||||
input[index] !== "\\"
|
||||
);
|
||||
length += output.write(input.slice(start, index), length, "utf8");
|
||||
continue;
|
||||
}
|
||||
const escaped = input[index + 1];
|
||||
|
||||
@@ -32,7 +32,7 @@ describe("Go producer module text", () => {
|
||||
|
||||
it("decodes Go quoting including byte, octal and Unicode escapes without JSON substitution", () => {
|
||||
const text =
|
||||
String.raw`build\t"key=quoted"="\a\v\xC3\xA9\303\251\u263a\U0001F680"`.replace(
|
||||
String.raw`build\t"key=quoted"="literal路𐐷\a\v\xC3\xA9\303\251\u263a\U0001F680 end"`.replace(
|
||||
"\\t",
|
||||
"\t",
|
||||
) +
|
||||
@@ -40,7 +40,7 @@ describe("Go producer module text", () => {
|
||||
"build\traw=`a\rb`\n";
|
||||
expect(parseGoModuleBytes(Buffer.from(text))).toMatchObject({
|
||||
settings: [
|
||||
{ key: "key=quoted", value: "\x07\x0béé☺🚀" },
|
||||
{ key: "key=quoted", value: "literal路𐐷\x07\x0béé☺🚀 end" },
|
||||
{ key: "raw", value: "ab" },
|
||||
],
|
||||
complete: true,
|
||||
|
||||
Reference in new issue
Block a user