From c6d5900c5db23adeaa563138eafff4b56dff08ae Mon Sep 17 00:00:00 2001 From: "Jurgen J. Vinju" Date: Mon, 8 Jan 2024 15:47:02 +0100 Subject: [PATCH] fixed bottleneck in tuple.equals --- .../io/usethesource/vallang/impl/persistent/Tuple.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/usethesource/vallang/impl/persistent/Tuple.java b/src/main/java/io/usethesource/vallang/impl/persistent/Tuple.java index 1ed92836a..30bdfa976 100644 --- a/src/main/java/io/usethesource/vallang/impl/persistent/Tuple.java +++ b/src/main/java/io/usethesource/vallang/impl/persistent/Tuple.java @@ -174,10 +174,11 @@ public boolean equals(@Nullable Object o) { if (o.getClass() == getClass()) { Tuple otherTuple = (Tuple) o; - if (getType() != otherTuple.getType()) { - return false; + // checking for the type will dynamically allocate memory + // because tuple types are computed lazily. + // so we skip this "fast failure" check + // if (getType() != otherTuple.getType()) { return false; } - } IValue[] otherElements = otherTuple.elements; int nrOfElements = elements.length;