@@ -23,77 +23,6 @@ const data = fs
2323\t\tconsole.error(e.stack);
2424\t}
2525\ttypeof process !== "undefined" && process.exit(1);
26- };` )
27-
28- /* Prevents V8 from retaining large "concatenated string" chains, which can cause OOMs.
29- Tested against `rtfeldman/elm-css` compilation.
30-
31- See the related discussion for context: https://discourse.elm-lang.org/t/guida-compiler-was-there-are-3-elm-compilers-written-in-elm/10329/34
32- and issue: https://github.com/guida-lang/compiler/issues/107
33- */
34- . replace ( `var _Bytes_read_string = F3(function(len, bytes, offset)
35- {
36- var string = '';
37- \tvar end = offset + len;
38- \tfor (; offset < end;)
39- \t{
40- \t\tvar byte = bytes.getUint8(offset++);
41- \t\tstring +=
42- \t\t\t(byte < 128)
43- \t\t\t\t? String.fromCharCode(byte)
44- \t\t\t\t:
45- \t\t\t((byte & 0xE0 /* 0b11100000 */) === 0xC0 /* 0b11000000 */)
46- \t\t\t\t? String.fromCharCode((byte & 0x1F /* 0b00011111 */) << 6 | bytes.getUint8(offset++) & 0x3F /* 0b00111111 */)
47- \t\t\t\t:
48- \t\t\t((byte & 0xF0 /* 0b11110000 */) === 0xE0 /* 0b11100000 */)
49- \t\t\t\t? String.fromCharCode(
50- \t\t\t\t\t(byte & 0xF /* 0b00001111 */) << 12
51- \t\t\t\t\t| (bytes.getUint8(offset++) & 0x3F /* 0b00111111 */) << 6
52- \t\t\t\t\t| bytes.getUint8(offset++) & 0x3F /* 0b00111111 */
53- \t\t\t\t)
54- \t\t\t\t:
55- \t\t\t\t(byte =
56- \t\t\t\t\t((byte & 0x7 /* 0b00000111 */) << 18
57- \t\t\t\t\t\t| (bytes.getUint8(offset++) & 0x3F /* 0b00111111 */) << 12
58- \t\t\t\t\t\t| (bytes.getUint8(offset++) & 0x3F /* 0b00111111 */) << 6
59- \t\t\t\t\t\t| bytes.getUint8(offset++) & 0x3F /* 0b00111111 */
60- \t\t\t\t\t) - 0x10000
61- \t\t\t\t, String.fromCharCode(Math.floor(byte / 0x400) + 0xD800, byte % 0x400 + 0xDC00)
62- \t\t\t\t);
63- \t}
64- \treturn _Utils_Tuple2(offset, string);
65- });` , `var _Bytes_read_string = F3(function(len, bytes, offset)
66- {
67- \tvar string = [];
68- \tvar end = offset + len;
69- \tfor (; offset < end;)
70- \t{
71- \t\tvar byte = bytes.getUint8(offset++);
72- \t\tstring.push(
73- \t\t\t(byte < 128)
74- \t\t\t\t? String.fromCharCode(byte)
75- \t\t\t\t:
76- \t\t\t((byte & 0xE0 /* 0b11100000 */) === 0xC0 /* 0b11000000 */)
77- \t\t\t\t? String.fromCharCode((byte & 0x1F /* 0b00011111 */) << 6 | bytes.getUint8(offset++) & 0x3F /* 0b00111111 */)
78- \t\t\t\t:
79- \t\t\t((byte & 0xF0 /* 0b11110000 */) === 0xE0 /* 0b11100000 */)
80- \t\t\t\t? String.fromCharCode(
81- \t\t\t\t\t(byte & 0xF /* 0b00001111 */) << 12
82- \t\t\t\t\t| (bytes.getUint8(offset++) & 0x3F /* 0b00111111 */) << 6
83- \t\t\t\t\t| bytes.getUint8(offset++) & 0x3F /* 0b00111111 */
84- \t\t\t\t)
85- \t\t\t\t:
86- \t\t\t\t(byte =
87- \t\t\t\t\t((byte & 0x7 /* 0b00000111 */) << 18
88- \t\t\t\t\t\t| (bytes.getUint8(offset++) & 0x3F /* 0b00111111 */) << 12
89- \t\t\t\t\t\t| (bytes.getUint8(offset++) & 0x3F /* 0b00111111 */) << 6
90- \t\t\t\t\t\t| bytes.getUint8(offset++) & 0x3F /* 0b00111111 */
91- \t\t\t\t\t) - 0x10000
92- \t\t\t\t, String.fromCharCode(Math.floor(byte / 0x400) + 0xD800, byte % 0x400 + 0xDC00)
93- \t\t\t\t)
94- \t\t);
95- \t}
96- \treturn _Utils_Tuple2(offset, string.join(''));
97- });` ) ;
26+ };` ) ;
9827
9928fs . writeFileSync ( path , data , { encoding : 'utf8' , flag : 'w' } ) ;
0 commit comments