mirror of
https://github.com/twitter/the-algorithm.git
synced 2025-01-05 00:51:55 +01:00
enhance: skip redundant arraySize comparison
This commit is contained in:
parent
138bb51997
commit
10604e10f3
@ -21,16 +21,12 @@ object IntersectionValueCalculator {
|
|||||||
x.remaining() >> 3 // divide 8
|
x.remaining() >> 3 // divide 8
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
def apply(x: ByteBuffer, y: ByteBuffer, intersectionIdLimit: Int): WorkerIntersectionValue = {
|
def apply(x: ByteBuffer, y: ByteBuffer, intersectionIdLimit: Int): WorkerIntersectionValue = {
|
||||||
|
|
||||||
val xSize = computeArraySize(x)
|
val xSize = computeArraySize(x)
|
||||||
val ySize = computeArraySize(y)
|
val ySize = computeArraySize(y)
|
||||||
|
|
||||||
val largerArray = if (xSize > ySize) x else y
|
val (largerArray, smallerArray) = if (xSize > ySize) (x, y) else (y, x)
|
||||||
val smallerArray = if (xSize > ySize) y else x
|
|
||||||
|
|
||||||
if (intersectionIdLimit == 0) {
|
if (intersectionIdLimit == 0) {
|
||||||
val result = computeIntersectionUsingBinarySearchOnLargerByteBuffer(smallerArray, largerArray)
|
val result = computeIntersectionUsingBinarySearchOnLargerByteBuffer(smallerArray, largerArray)
|
||||||
|
Loading…
Reference in New Issue
Block a user