You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2020/04/14 18:41:24 UTC

[GitHub] [cordova-android] timbru31 commented on a change in pull request #948: Feature: JVM Args flag

timbru31 commented on a change in pull request #948: Feature: JVM Args flag
URL: https://github.com/apache/cordova-android/pull/948#discussion_r408352472
 
 

 ##########
 File path: bin/templates/cordova/lib/config/GradlePropertiesParser.js
 ##########
 @@ -103,6 +110,34 @@ class GradlePropertiesParser {
         });
     }
 
+    _isJVMMemoryLessThanRecommended (memoryValue, recommendedMemoryValue) {
+        const UNIT = 2;
+        const SIZE = 1;
+        const regex = /-Xmx+([0-9]+)+([mMgGkK])/;
+
+        const recommendedCapture = regex.exec(recommendedMemoryValue);
+        const recommendedBase = this._getBaseJVMSize(recommendedCapture[SIZE], recommendedCapture[UNIT]);
+        const memoryCapture = regex.exec(memoryValue);
+        const memoryBase = this._getBaseJVMSize(memoryCapture[SIZE], memoryCapture[UNIT]);
+
+        return memoryBase < recommendedBase;
+    }
+
+    _getBaseJVMSize (size, unit) {
+        const KILOBYTE = 1024;
+        const MEGABYTE = 1048576;
+        const GIGABYTE = 1073741824;
+
+        switch (unit.toLowerCase()) {
+        case 'k': return size * KILOBYTE;
+        case 'm': return size * MEGABYTE;
+        case 'g': return size * GIGABYTE;
+        }
+
+        events.emit('warn', '[Gradle Properties] Unknown memory size unit (' + unit + ')');
 
 Review comment:
   I'd prefer a template string instead.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org