terser 5.18.1 → 5.18.2

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.
package/CHANGELOG.md CHANGED
@@ -1,9 +1,12 @@
1
1
  # Changelog
2
2
 
3
- ## v7.18.1
3
+ ## v5.18.2
4
+ - Stop using recursion in hoisted defuns fix.
5
+
6
+ ## v5.18.1
4
7
  - Fix major performance issue caused by hoisted defuns' scopes bugfix.
5
8
 
6
- ## v7.18.0
9
+ ## v5.18.0
7
10
  - Add new `/*@__MANGLE_PROP__*/` annotation, to mark properties that should be mangled.
8
11
 
9
12
  ## v5.17.7
@@ -16013,23 +16013,25 @@ function handle_defined_after_hoist(parent) {
16013
16013
 
16014
16014
  // find the index in `found_symbols`, with some special rules:
16015
16015
  const find = (sym_id, starting_at = 0, must_be_write = false) => {
16016
- const index = found_symbols.indexOf(sym_id, starting_at);
16016
+ let index = starting_at;
16017
16017
 
16018
- if (
16019
- defun_range
16020
- && index >= defun_range.start
16021
- && index < defun_range.end
16022
- ) {
16023
- return find(sym_id, defun_range.end, must_be_write);
16024
- } else if (
16025
- must_be_write
16026
- && index >= 0
16027
- && !found_symbol_writes.has(index)
16028
- ) {
16029
- return find(sym_id, index + 1, must_be_write);
16030
- } else {
16031
- return index;
16018
+ for (;;) {
16019
+ index = found_symbols.indexOf(sym_id, index);
16020
+
16021
+ if (index === -1) {
16022
+ break;
16023
+ } else if (index >= defun_range.start && index < defun_range.end) {
16024
+ index = defun_range.end;
16025
+ continue;
16026
+ } else if (must_be_write && !found_symbol_writes.has(index)) {
16027
+ index++;
16028
+ continue;
16029
+ } else {
16030
+ break;
16031
+ }
16032
16032
  }
16033
+
16034
+ return index;
16033
16035
  };
16034
16036
 
16035
16037
  const read_defun_at = find(fname_def.id);
@@ -592,23 +592,25 @@ function handle_defined_after_hoist(parent) {
592
592
 
593
593
  // find the index in `found_symbols`, with some special rules:
594
594
  const find = (sym_id, starting_at = 0, must_be_write = false) => {
595
- const index = found_symbols.indexOf(sym_id, starting_at);
596
-
597
- if (
598
- defun_range
599
- && index >= defun_range.start
600
- && index < defun_range.end
601
- ) {
602
- return find(sym_id, defun_range.end, must_be_write);
603
- } else if (
604
- must_be_write
605
- && index >= 0
606
- && !found_symbol_writes.has(index)
607
- ) {
608
- return find(sym_id, index + 1, must_be_write);
609
- } else {
610
- return index;
595
+ let index = starting_at;
596
+
597
+ for (;;) {
598
+ index = found_symbols.indexOf(sym_id, index);
599
+
600
+ if (index === -1) {
601
+ break;
602
+ } else if (index >= defun_range.start && index < defun_range.end) {
603
+ index = defun_range.end;
604
+ continue;
605
+ } else if (must_be_write && !found_symbol_writes.has(index)) {
606
+ index++;
607
+ continue;
608
+ } else {
609
+ break;
610
+ }
611
611
  }
612
+
613
+ return index;
612
614
  };
613
615
 
614
616
  const read_defun_at = find(fname_def.id);
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "homepage": "https://terser.org",
5
5
  "author": "Mihai Bazon <mihai.bazon@gmail.com> (http://lisperator.net/)",
6
6
  "license": "BSD-2-Clause",
7
- "version": "5.18.1",
7
+ "version": "5.18.2",
8
8
  "engines": {
9
9
  "node": ">=10"
10
10
  },