Skip to content

Commit

Permalink
[Java] Improvements after merge of PR #198.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjpt777 committed Jan 15, 2020
1 parent b5987ad commit 9159c47
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 24 deletions.
20 changes: 7 additions & 13 deletions agrona/src/main/java/org/agrona/collections/MutableInteger.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public int intValue()

public long longValue()
{
return (long)value;
return value;
}

public float floatValue()
Expand All @@ -71,7 +71,7 @@ public float floatValue()

public double doubleValue()
{
return (double)value;
return value;
}

public void increment()
Expand All @@ -81,15 +81,12 @@ public void increment()

public int incrementAndGet()
{
increment();
return get();
return ++value;
}

public int getAndIncrement()
{
final int result = get();
increment();
return result;
return value++;
}

public void decrement()
Expand All @@ -99,15 +96,12 @@ public void decrement()

public int decrementAndGet()
{
decrement();
return get();
return --value;
}

public int getAndDecrement()
{
final int result = get();
decrement();
return result;
return value--;
}

public boolean equals(final Object o)
Expand Down Expand Up @@ -144,6 +138,6 @@ public int compareTo(final MutableInteger that)

public static int compare(final int lhs, final int rhs)
{
return lhs < rhs ? -1 : (lhs == rhs ? 0 : 1);
return Integer.compare(lhs, rhs);
}
}
16 changes: 5 additions & 11 deletions agrona/src/main/java/org/agrona/collections/MutableLong.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,12 @@ public void increment()

public long incrementAndGet()
{
increment();
return get();
return ++value;
}

public long getAndIncrement()
{
final long result = get();
increment();
return result;
return value++;
}

public void decrement()
Expand All @@ -99,15 +96,12 @@ public void decrement()

public long decrementAndGet()
{
decrement();
return get();
return --value;
}

public long getAndDecrement()
{
final long result = get();
decrement();
return result;
return value--;
}

public boolean equals(final Object o)
Expand Down Expand Up @@ -144,6 +138,6 @@ public int compareTo(final MutableLong that)

public static int compare(final long lhs, final long rhs)
{
return lhs < rhs ? -1 : (lhs == rhs ? 0 : 1);
return Long.compare(lhs, rhs);
}
}

0 comments on commit 9159c47

Please sign in to comment.