porffor 0.57.6 → 0.57.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,9 +28,9 @@ export const signedLEB128 = n => {
28
28
  // just input for small numbers (for perf as common)
29
29
  if (n >= 0 && n <= 63) return [ n ];
30
30
  if (n >= -64 && n <= 0) return [ 128 + n ];
31
+ if (n >= 0 && n <= 8191) return [ 128 + (n % 128), Math.floor(n / 128) ];
31
32
 
32
33
  const buffer = [];
33
-
34
34
  while (true) {
35
35
  let byte = n & 0x7f;
36
36
  n >>= 7;
@@ -53,6 +53,7 @@ export const unsignedLEB128 = n => {
53
53
 
54
54
  // just input for small numbers (for perf as common)
55
55
  if (n >= 0 && n <= 127) return [ n ];
56
+ if (n >= 0 && n <= 16383) return [ 128 + (n % 128), Math.floor(n / 128) ];
56
57
 
57
58
  const buffer = [];
58
59
  do {
@@ -63,6 +64,7 @@ export const unsignedLEB128 = n => {
63
64
  }
64
65
  buffer.push(byte);
65
66
  } while (n !== 0);
67
+
66
68
  return buffer;
67
69
  };
68
70
 
@@ -122,14 +124,13 @@ export const big_unsignedLEB128 = n => {
122
124
  return buffer;
123
125
  };
124
126
 
125
- export const read_signedLEB128 = _input => {
126
- const input = [..._input];
127
+ export const read_signedLEB128 = input => {
127
128
  let result = 0, shift = 0;
128
129
 
130
+ let i = 0;
129
131
  while (true) {
130
- const byte = input.shift();
132
+ const byte = input[i++];
131
133
  result |= (byte & 0x7f) << shift;
132
-
133
134
  shift += 7;
134
135
 
135
136
  if ((0x80 & byte) === 0) {
@@ -143,14 +144,13 @@ export const read_signedLEB128 = _input => {
143
144
  };
144
145
 
145
146
  // todo: check this with large unsigned values
146
- export const read_unsignedLEB128 = _input => {
147
- const input = [..._input];
147
+ export const read_unsignedLEB128 = input => {
148
148
  let result = 0, shift = 0;
149
149
 
150
+ let i = 0;
150
151
  while (true) {
151
- const byte = input.shift();
152
+ const byte = input[i++];
152
153
  result |= (byte & 0x7f) << shift;
153
-
154
154
  shift += 7;
155
155
 
156
156
  if ((0x80 & byte) === 0) {
@@ -184,6 +184,7 @@ export const signedLEB128_into = (n, buffer) => {
184
184
  // just input for small numbers (for perf as common)
185
185
  if (n >= 0 && n <= 63) return buffer.push(n);
186
186
  if (n >= -64 && n <= 0) return buffer.push(128 + n);
187
+ if (n >= 0 && n <= 8191) return buffer.push(128 + (n % 128), Math.floor(n / 128));
187
188
 
188
189
  while (true) {
189
190
  let byte = n & 0x7f;
@@ -205,6 +206,7 @@ export const unsignedLEB128_into = (n, buffer) => {
205
206
 
206
207
  // just input for small numbers (for perf as common)
207
208
  if (n >= 0 && n <= 127) return buffer.push(n);
209
+ if (n >= 0 && n <= 16383) return buffer.push(128 + (n % 128), Math.floor(n / 128));
208
210
 
209
211
  do {
210
212
  let byte = n & 0x7f;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "porffor",
3
3
  "description": "An ahead-of-time JavaScript compiler",
4
- "version": "0.57.6",
4
+ "version": "0.57.7",
5
5
  "author": "Oliver Medhurst <honk@goose.icu>",
6
6
  "license": "MIT",
7
7
  "scripts": {},
package/runtime/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import fs from 'node:fs';
3
- globalThis.version = '0.57.6';
3
+ globalThis.version = '0.57.7';
4
4
 
5
5
  // deno compat
6
6
  if (typeof process === 'undefined' && typeof Deno !== 'undefined') {