From 97fefec1c95c8ff80bd1315e19233cc75f5fba19 Mon Sep 17 00:00:00 2001 From: Lionel Sambuc Date: Fri, 10 Jan 2020 11:00:59 +0100 Subject: [PATCH] Optimisation: Reworked comparison for SpaceFields --- src/database/space_index.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/database/space_index.rs b/src/database/space_index.rs index 7c921b6..761f0f6 100644 --- a/src/database/space_index.rs +++ b/src/database/space_index.rs @@ -68,7 +68,15 @@ impl SpaceFields { impl PartialEq for SpaceFields { fn eq(&self, other: &Self) -> bool { - self.space_id == other.space_id && self.value == other.value + // WARNING: We ignore the spaceID, as we know it will always be true + // because of our usage of this. + + // This assumption has to be maintained or the test added back. + //self.value == other.value + + // First compare on the number field (cheap and fast), then do the String comparison. + // Safety first + self.value == other.value && self.space_id == other.space_id } }