From 10604e10f3761a448ba6a1bfe12642456adda5a7 Mon Sep 17 00:00:00 2001 From: ethanknights Date: Thu, 6 Apr 2023 17:33:08 +0100 Subject: [PATCH] enhance: skip redundant arraySize comparison --- .../util/IntersectionValueCalculator.scala | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/graph-feature-service/src/main/scala/com/twitter/graph_feature_service/util/IntersectionValueCalculator.scala b/graph-feature-service/src/main/scala/com/twitter/graph_feature_service/util/IntersectionValueCalculator.scala index 4e1376cc4..24709dbb6 100644 --- a/graph-feature-service/src/main/scala/com/twitter/graph_feature_service/util/IntersectionValueCalculator.scala +++ b/graph-feature-service/src/main/scala/com/twitter/graph_feature_service/util/IntersectionValueCalculator.scala @@ -21,16 +21,12 @@ object IntersectionValueCalculator { x.remaining() >> 3 // divide 8 } - /** - * - */ def apply(x: ByteBuffer, y: ByteBuffer, intersectionIdLimit: Int): WorkerIntersectionValue = { val xSize = computeArraySize(x) val ySize = computeArraySize(y) - val largerArray = if (xSize > ySize) x else y - val smallerArray = if (xSize > ySize) y else x + val (largerArray, smallerArray) = if (xSize > ySize) (x, y) else (y, x) if (intersectionIdLimit == 0) { val result = computeIntersectionUsingBinarySearchOnLargerByteBuffer(smallerArray, largerArray)