Skip to content

improve(Address): Optimise address comparisons#1358

Merged
pxrl merged 2 commits intomasterfrom
pxrl/addressOptimise
Mar 23, 2026
Merged

improve(Address): Optimise address comparisons#1358
pxrl merged 2 commits intomasterfrom
pxrl/addressOptimise

Conversation

@pxrl
Copy link
Copy Markdown
Collaborator

@pxrl pxrl commented Mar 23, 2026

It's much more efficient to compare the rawAddress directly. Proposed by Claude.

pxrl added 2 commits March 23, 2026 14:55
To esablish a behavioural baseline in advance of introducing a
performance optimisation.
It's much more efficient to compare the rawAddress directly. Proposed by
Claude.
@pxrl
Copy link
Copy Markdown
Collaborator Author

pxrl commented Mar 23, 2026

  Compares the 32-byte rawAddress arrays directly instead of converting through hex strings and BigNumber. Removes the toBigNumber() method and bnAddress cache field, which were only used by compare().                        
                                                                      
  - Warm cache: ~75-100x faster (2,500-3,500 ns/op → 35 ns/op)                                                                                                                                                                   
  - Cold cache: ~117x faster (9,000 ns/op → 77 ns/op)                                                                                                                                                                            
  - Sort of 1,000 addresses: ~37x faster (26ms → 0.7ms)

@pxrl pxrl requested review from bmzig and dijanin-brat March 23, 2026 15:19
Base automatically changed from pxrl/addressBaseline to master March 23, 2026 22:23
@pxrl pxrl merged commit a2f34b4 into master Mar 23, 2026
4 checks passed
@pxrl pxrl deleted the pxrl/addressOptimise branch March 23, 2026 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants