diff options
author | Vincent Ambo <mail@tazj.in> | 2024-08-18T20·22+0300 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2024-08-19T13·19+0000 |
commit | 0d6d31bc66928252f2ea9d53fc7a5e13d4893c92 (patch) | |
tree | 4782f82399bc2ff1228580420d73ee0960704186 /users | |
parent | a521f9e5f891b6a8af9c4e99be52614c75543c2a (diff) |
feat(tazjin/german-string): add pointer equality check in Eq r/8534
This can short-circuit two large string comparisons. Change-Id: If45e7cf33921fe571482dc710c27ef8cc7c70885 Reviewed-on: https://cl.tvl.fyi/c/depot/+/12245 Autosubmit: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI Reviewed-by: tazjin <tazjin@tvl.su>
Diffstat (limited to 'users')
-rw-r--r-- | users/tazjin/german-string/src/lib.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/users/tazjin/german-string/src/lib.rs b/users/tazjin/german-string/src/lib.rs index e696af7cbe62..09ac3384d916 100644 --- a/users/tazjin/german-string/src/lib.rs +++ b/users/tazjin/german-string/src/lib.rs @@ -112,8 +112,9 @@ impl PartialEq for GermanString { if self.len() <= 12 { return self.0.small.data[..self.len()] == other.0.small.data[..other.len()]; } - return self.0.large.prefix == other.0.large.prefix - && self.as_bytes() == other.as_bytes(); + return self.0.large.data == other.0.large.data + || (self.0.large.prefix == other.0.large.prefix + && self.as_bytes() == other.as_bytes()); } } } |