Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: PercentileTypeHelpers, use explicit comparison operator #5815

Merged
merged 1 commit into from
Jul 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private static int upperBound(ObjectChunk<Object, ? extends Values> valuesToSear
while (lo < hi) {
final int mid = (lo + hi) >>> 1;
final Object testValue = valuesToSearch.get(mid);
final boolean moveHi = gt(testValue, searchValue);
final boolean moveHi = ObjectComparisons.gt(testValue, searchValue);
if (moveHi) {
hi = mid;
} else {
Expand All @@ -115,11 +115,4 @@ private static int upperBound(ObjectChunk<Object, ? extends Values> valuesToSear
return hi;
}

private static int doComparison(Object lhs, Object rhs) {
return ObjectComparisons.compare(lhs, rhs);
}

private static boolean gt(Object lhs, Object rhs) {
return doComparison(lhs, rhs) > 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private static int upperBound(ByteChunk<? extends Values> valuesToSearch, int lo
while (lo < hi) {
final int mid = (lo + hi) >>> 1;
final byte testValue = valuesToSearch.get(mid);
final boolean moveHi = gt(testValue, searchValue);
final boolean moveHi = ByteComparisons.gt(testValue, searchValue);
if (moveHi) {
hi = mid;
} else {
Expand All @@ -117,12 +117,4 @@ private static int upperBound(ByteChunk<? extends Values> valuesToSearch, int lo

return hi;
}

private static int doComparison(byte lhs, byte rhs) {
return ByteComparisons.compare(lhs, rhs);
}

private static boolean gt(byte lhs, byte rhs) {
return doComparison(lhs, rhs) > 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private static int upperBound(CharChunk<? extends Values> valuesToSearch, int lo
while (lo < hi) {
final int mid = (lo + hi) >>> 1;
final char testValue = valuesToSearch.get(mid);
final boolean moveHi = gt(testValue, searchValue);
final boolean moveHi = CharComparisons.gt(testValue, searchValue);
if (moveHi) {
hi = mid;
} else {
Expand All @@ -113,12 +113,4 @@ private static int upperBound(CharChunk<? extends Values> valuesToSearch, int lo

return hi;
}

private static int doComparison(char lhs, char rhs) {
return CharComparisons.compare(lhs, rhs);
}

private static boolean gt(char lhs, char rhs) {
return doComparison(lhs, rhs) > 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private static int upperBound(DoubleChunk<? extends Values> valuesToSearch, int
while (lo < hi) {
final int mid = (lo + hi) >>> 1;
final double testValue = valuesToSearch.get(mid);
final boolean moveHi = gt(testValue, searchValue);
final boolean moveHi = DoubleComparisons.gt(testValue, searchValue);
if (moveHi) {
hi = mid;
} else {
Expand All @@ -117,12 +117,4 @@ private static int upperBound(DoubleChunk<? extends Values> valuesToSearch, int

return hi;
}

private static int doComparison(double lhs, double rhs) {
return DoubleComparisons.compare(lhs, rhs);
}

private static boolean gt(double lhs, double rhs) {
return doComparison(lhs, rhs) > 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private static int upperBound(FloatChunk<? extends Values> valuesToSearch, int l
while (lo < hi) {
final int mid = (lo + hi) >>> 1;
final float testValue = valuesToSearch.get(mid);
final boolean moveHi = gt(testValue, searchValue);
final boolean moveHi = FloatComparisons.gt(testValue, searchValue);
if (moveHi) {
hi = mid;
} else {
Expand All @@ -117,12 +117,4 @@ private static int upperBound(FloatChunk<? extends Values> valuesToSearch, int l

return hi;
}

private static int doComparison(float lhs, float rhs) {
return FloatComparisons.compare(lhs, rhs);
}

private static boolean gt(float lhs, float rhs) {
return doComparison(lhs, rhs) > 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private static int upperBound(LongChunk<? extends Values> valuesToSearch, int lo
while (lo < hi) {
final int mid = (lo + hi) >>> 1;
final long testValue = valuesToSearch.get(mid);
final boolean moveHi = gt(testValue, searchValue);
final boolean moveHi = LongComparisons.gt(testValue, searchValue);
if (moveHi) {
hi = mid;
} else {
Expand All @@ -113,11 +113,4 @@ private static int upperBound(LongChunk<? extends Values> valuesToSearch, int lo
return hi;
}

private static int doComparison(long lhs, long rhs) {
return LongComparisons.compare(lhs, rhs);
}

private static boolean gt(long lhs, long rhs) {
return doComparison(lhs, rhs) > 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private static int upperBound(IntChunk<? extends Values> valuesToSearch, int lo,
while (lo < hi) {
final int mid = (lo + hi) >>> 1;
final int testValue = valuesToSearch.get(mid);
final boolean moveHi = gt(testValue, searchValue);
final boolean moveHi = IntComparisons.gt(testValue, searchValue);
if (moveHi) {
hi = mid;
} else {
Expand All @@ -117,12 +117,4 @@ private static int upperBound(IntChunk<? extends Values> valuesToSearch, int lo,

return hi;
}

private static int doComparison(int lhs, int rhs) {
return IntComparisons.compare(lhs, rhs);
}

private static boolean gt(int lhs, int rhs) {
return doComparison(lhs, rhs) > 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private static int upperBound(LongChunk<? extends Values> valuesToSearch, int lo
while (lo < hi) {
final int mid = (lo + hi) >>> 1;
final long testValue = valuesToSearch.get(mid);
final boolean moveHi = gt(testValue, searchValue);
final boolean moveHi = LongComparisons.gt(testValue, searchValue);
if (moveHi) {
hi = mid;
} else {
Expand All @@ -117,12 +117,4 @@ private static int upperBound(LongChunk<? extends Values> valuesToSearch, int lo

return hi;
}

private static int doComparison(long lhs, long rhs) {
return LongComparisons.compare(lhs, rhs);
}

private static boolean gt(long lhs, long rhs) {
return doComparison(lhs, rhs) > 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private static int upperBound(ObjectChunk<Object, ? extends Values> valuesToSear
while (lo < hi) {
final int mid = (lo + hi) >>> 1;
final Object testValue = valuesToSearch.get(mid);
final boolean moveHi = gt(testValue, searchValue);
final boolean moveHi = ObjectComparisons.gt(testValue, searchValue);
if (moveHi) {
hi = mid;
} else {
Expand All @@ -119,12 +119,4 @@ private static int upperBound(ObjectChunk<Object, ? extends Values> valuesToSear

return hi;
}

private static int doComparison(Object lhs, Object rhs) {
return ObjectComparisons.compare(lhs, rhs);
}

private static boolean gt(Object lhs, Object rhs) {
return doComparison(lhs, rhs) > 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private static int upperBound(ShortChunk<? extends Values> valuesToSearch, int l
while (lo < hi) {
final int mid = (lo + hi) >>> 1;
final short testValue = valuesToSearch.get(mid);
final boolean moveHi = gt(testValue, searchValue);
final boolean moveHi = ShortComparisons.gt(testValue, searchValue);
if (moveHi) {
hi = mid;
} else {
Expand All @@ -117,12 +117,4 @@ private static int upperBound(ShortChunk<? extends Values> valuesToSearch, int l

return hi;
}

private static int doComparison(short lhs, short rhs) {
return ShortComparisons.compare(lhs, rhs);
}

private static boolean gt(short lhs, short rhs) {
return doComparison(lhs, rhs) > 0;
}
}
Loading