perf: avoid calling Matching::add in a loop #329

Merged
ada4a merged 6 commits from ada4a/mergiraf:matching_avoid_add into main 2025-04-17 16:21:07 +02:00
Owner

It calls HashMap::insert internally. One should avoid calling that
method in a loop, and instead pass the iterator into HashMap::extend,
so that the map can (hopefully) preallocate enough space.

This PR introduces Matching::extend which does exactly that.

The other thing Matching::add does is call Matching::remove, which I
couldn't find a way to "serialize", so it's still called in the loop.
That can be an area for further improvement.

It calls `HashMap::insert` internally. One should avoid calling that method in a loop, and instead pass the iterator into `HashMap::extend`, so that the map can (hopefully) preallocate enough space. This PR introduces `Matching::extend` which does exactly that. The other thing `Matching::add` does is call `Matching::remove`, which I couldn't find a way to "serialize", so it's still called in the loop. That can be an area for further improvement.
ada4a changed title from perf(Matching): avoid caling Self::add in a loop to perf: avoid caling Matching::add in a loop 2025-04-17 14:50:42 +02:00
wetneb approved these changes 2025-04-17 15:38:43 +02:00
ada4a changed title from perf: avoid caling Matching::add in a loop to perf: avoid calling Matching::add in a loop 2025-04-17 15:48:04 +02:00
Author
Owner

rebased onto main

rebased onto main
ada4a force-pushed matching_avoid_add from 4ad971eccc to 803e3fab50 2025-04-17 16:12:02 +02:00 Compare
ada4a merged commit ef4e2bb13d into main 2025-04-17 16:21:07 +02:00
ada4a deleted branch matching_avoid_add 2025-04-17 16:21:09 +02:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: mergiraf/mergiraf#329
No description provided.