fluo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ktur...@apache.org
Subject incubator-fluo git commit: fixes #826
Date Fri, 28 Apr 2017 21:48:20 GMT
Repository: incubator-fluo
Updated Branches:
  refs/heads/master 38dc66d15 -> a1c869ca5


fixes #826

-Updated hashCode() to direct access array
-Updated compareTo() to direct access array
-Remove calls to length() where direct access was acceptable

Project: http://git-wip-us.apache.org/repos/asf/incubator-fluo/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-fluo/commit/a1c869ca
Tree: http://git-wip-us.apache.org/repos/asf/incubator-fluo/tree/a1c869ca
Diff: http://git-wip-us.apache.org/repos/asf/incubator-fluo/diff/a1c869ca

Branch: refs/heads/master
Commit: a1c869ca508a020d028f8942225100523d5379a2
Parents: 38dc66d
Author: Christopher McTague <cjmctague@vwc.edu>
Authored: Fri Apr 28 16:37:03 2017 -0400
Committer: Christopher McTague <cjmctague@vwc.edu>
Committed: Fri Apr 28 16:37:03 2017 -0400

----------------------------------------------------------------------
 .../java/org/apache/fluo/api/data/Bytes.java    | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-fluo/blob/a1c869ca/modules/api/src/main/java/org/apache/fluo/api/data/Bytes.java
----------------------------------------------------------------------
diff --git a/modules/api/src/main/java/org/apache/fluo/api/data/Bytes.java b/modules/api/src/main/java/org/apache/fluo/api/data/Bytes.java
index e5bde63..1e66a22 100644
--- a/modules/api/src/main/java/org/apache/fluo/api/data/Bytes.java
+++ b/modules/api/src/main/java/org/apache/fluo/api/data/Bytes.java
@@ -202,17 +202,16 @@ public final class Bytes implements Comparable<Bytes>, Serializable
{
     } else if (this.length == this.data.length && other.length == other.data.length)
{
       return UnsignedBytes.lexicographicalComparator().compare(this.data, other.data);
     } else {
-      int minLen = Math.min(this.length(), other.length());
-
-      for (int i = 0; i < minLen; i++) {
-        int a = (this.byteAt(i) & 0xff);
-        int b = (other.byteAt(i) & 0xff);
+      int minLen = Math.min(this.length, other.length);
+      for (int i = this.offset, j = other.offset; i < minLen; i++, j++) {
+        int a = (this.data[i] & 0xff);
+        int b = (other.data[j] & 0xff);
 
         if (a != b) {
           return a - b;
         }
       }
-      return this.length() - other.length();
+      return this.length - other.length;
     }
   }
 
@@ -229,7 +228,7 @@ public final class Bytes implements Comparable<Bytes>, Serializable
{
     if (other instanceof Bytes) {
       Bytes ob = (Bytes) other;
 
-      if (length() != ob.length()) {
+      if (length != ob.length) {
         return false;
       }
 
@@ -242,8 +241,9 @@ public final class Bytes implements Comparable<Bytes>, Serializable
{
   public final int hashCode() {
     if (hashCode == 0) {
       int hash = 1;
-      for (int i = 0; i < length(); i++) {
-        hash = (31 * hash) + byteAt(i);
+      int end = offset + length;
+      for (int i = offset; i < end; i++) {
+        hash = (31 * hash) + data[i];
       }
       hashCode = hash;
     }
@@ -457,7 +457,7 @@ public final class Bytes implements Comparable<Bytes>, Serializable
{
     }
 
     public BytesBuilder append(Bytes b) {
-      ensureCapacity(len + b.length());
+      ensureCapacity(len + b.length);
       System.arraycopy(b.data, b.offset, ba, len, b.length);
       len += b.length();
       return this;


Mime
View raw message