From 1dfe3d962f50b8fc11c58caa74bb3be0e1a57222 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Thu, 10 Sep 2015 19:33:24 -0700 Subject: [PATCH] Hasher cleanup and simplification --- F-Droid/src/org/fdroid/fdroid/Hasher.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/F-Droid/src/org/fdroid/fdroid/Hasher.java b/F-Droid/src/org/fdroid/fdroid/Hasher.java index b55a0d26f..d8b905df4 100644 --- a/F-Droid/src/org/fdroid/fdroid/Hasher.java +++ b/F-Droid/src/org/fdroid/fdroid/Hasher.java @@ -59,9 +59,10 @@ public class Hasher { // specified in the constructor. This will return a cached value // on subsequent invocations. Returns the empty string on failure. public String getHash() { - if (hashCache != null) + if (hashCache != null) { return hashCache; - else if (file != null) { + } + if (file != null) { byte[] buffer = new byte[1024]; int read; InputStream input = null; @@ -85,9 +86,12 @@ public class Hasher { // returning true if they are equal. The empty string and null are // considered non-matching. public boolean match(String otherHash) { - if (hashCache == null) getHash(); - if (otherHash == null || hashCache.equals("")) + if (otherHash == null) { return false; + } + if (hashCache == null) { + getHash(); + } return hashCache.equals(otherHash.toLowerCase(Locale.ENGLISH)); }