浏览代码

Apple M1 performance fix

sanex 3 年之前
父节点
当前提交
0443111d09
共有 3 个文件被更改,包括 6 次插入4 次删除
  1. 1 0
      CHANGELOG.md
  2. 1 1
      package.json
  3. 4 3
      src/utils/NumberUtils.ts

+ 1 - 0
CHANGELOG.md

@@ -3,6 +3,7 @@ Change Log
 v3.0.1
 ---
 * Dependencies update
+* Fixed performance for Apple M1 chip
 
 v3.0.0
 ---

+ 1 - 1
package.json

@@ -111,7 +111,7 @@
     "test:mocha": "mocha --require ts-node/register --require source-map-support/register test/index.spec.ts --exit",
     "test:mocha-coverage": "nyc --reporter text-summary --no-clean yarn run test:mocha",
     "test:mocha-coverage:report": "nyc report --reporter=lcov",
-    "test:mocha-memory-performance": "cross-env NODE_OPTIONS=--max-old-space-size=220 mocha --require ts-node/register test/performance-tests/JavaScriptObfuscatorMemory.spec.ts",
+    "test:mocha-memory-performance": "cross-env NODE_OPTIONS=--max-old-space-size=230 mocha --require ts-node/register test/performance-tests/JavaScriptObfuscatorMemory.spec.ts",
     "test": "yarn run test:full",
     "eslint": "eslint src/**/*.ts",
     "git:addFiles": "git add .",

+ 4 - 3
src/utils/NumberUtils.ts

@@ -104,14 +104,15 @@ export class NumberUtils {
             currentFactor <= root;
             currentFactor += incrementValue
         ) {
-            if (number % currentFactor !== 0) {
+            const compliment: number = number / currentFactor;
+            const check = (number - Math.floor(compliment) * currentFactor) !== 0;
+
+            if (check) {
                 continue;
             }
 
             factors.push(...[-currentFactor, currentFactor]);
 
-            const compliment: number = number / currentFactor;
-
             if (compliment !== currentFactor) {
                 factors.push(...[-compliment, compliment]);
             }