cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purplecabb...@apache.org
Subject cordova-plugin-network-information git commit: Performance-related fix
Date Tue, 28 Jul 2015 21:30:12 GMT
Repository: cordova-plugin-network-information
Updated Branches:
  refs/heads/master a87effc43 -> 6550b937d


Performance-related fix

Move all conversions to line 236, saving ~14 tests

Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/commit/6550b937
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/tree/6550b937
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/diff/6550b937

Branch: refs/heads/master
Commit: 6550b937d0d437183984437deb452cbdd653ac18
Parents: a87effc
Author: Sid Ferreira <sid@ferreiraz.com.br>
Authored: Tue Jul 28 16:55:07 2015 -0300
Committer: Sid Ferreira <sid@ferreiraz.com.br>
Committed: Tue Jul 28 16:55:07 2015 -0300

----------------------------------------------------------------------
 src/android/NetworkManager.java | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information/blob/6550b937/src/android/NetworkManager.java
----------------------------------------------------------------------
diff --git a/src/android/NetworkManager.java b/src/android/NetworkManager.java
index d4cde23..ac0faae 100755
--- a/src/android/NetworkManager.java
+++ b/src/android/NetworkManager.java
@@ -233,32 +233,32 @@ public class NetworkManager extends CordovaPlugin {
      */
     private String getType(NetworkInfo info) {
         if (info != null) {
-            String type = info.getTypeName();
+            String type = info.getTypeName().toLowerCase(Locale.US);
 
             Log.d("CordovaNetworkManager", "toLower : " + type.toLowerCase());
             Log.d("CordovaNetworkManager", "wifi : " + WIFI);
-            if (type.toLowerCase(Locale.US).equals(WIFI)) {
+            if (type.equals(WIFI)) {
                 return TYPE_WIFI;
             }
-            else if (type.toLowerCase(Locale.US).equals(MOBILE) || type.toLowerCase(Locale.US).equals(CELLULAR))
{
+            else if (type.equals(MOBILE) || type.equals(CELLULAR)) {
                 type = info.getSubtypeName();
-                if (type.toLowerCase(Locale.US).equals(GSM) ||
-                        type.toLowerCase(Locale.US).equals(GPRS) ||
-                        type.toLowerCase(Locale.US).equals(EDGE)) {
+                if (type.equals(GSM) ||
+                        type.equals(GPRS) ||
+                        type.equals(EDGE)) {
                     return TYPE_2G;
                 }
-                else if (type.toLowerCase(Locale.US).startsWith(CDMA) ||
-                        type.toLowerCase(Locale.US).equals(UMTS) ||
-                        type.toLowerCase(Locale.US).equals(ONEXRTT) ||
-                        type.toLowerCase(Locale.US).equals(EHRPD) ||
-                        type.toLowerCase(Locale.US).equals(HSUPA) ||
-                        type.toLowerCase(Locale.US).equals(HSDPA) ||
-                        type.toLowerCase(Locale.US).equals(HSPA)) {
+                else if (type.startsWith(CDMA) ||
+                        type.equals(UMTS) ||
+                        type.equals(ONEXRTT) ||
+                        type.equals(EHRPD) ||
+                        type.equals(HSUPA) ||
+                        type.equals(HSDPA) ||
+                        type.equals(HSPA)) {
                     return TYPE_3G;
                 }
-                else if (type.toLowerCase(Locale.US).equals(LTE) ||
-                        type.toLowerCase(Locale.US).equals(UMB) ||
-                        type.toLowerCase(Locale.US).equals(HSPA_PLUS)) {
+                else if (type.equals(LTE) ||
+                        type.equals(UMB) ||
+                        type.equals(HSPA_PLUS)) {
                     return TYPE_4G;
                 }
             }


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


Mime
View raw message