Skip to content

osd_publish_batch : optimize the Fact loop - use const ref to avoid u…#113

Merged
henkwiedig merged 1 commit intoOpenIPC:masterfrom
GoreProgrammer:master
Jan 6, 2026
Merged

osd_publish_batch : optimize the Fact loop - use const ref to avoid u…#113
henkwiedig merged 1 commit intoOpenIPC:masterfrom
GoreProgrammer:master

Conversation

@GoreProgrammer
Copy link
Contributor

@GoreProgrammer GoreProgrammer commented Jan 4, 2026

Since Fact contains FactMeta struct and an std:: variant field that in turn can contain a string, its copying is not an entirely trivial operation. We can avoid the extra Fact copying operations by using const reference in the loop:

for (const Fact& fact: *facts)

instead of the original

for (Fact fact : *facts)

Another option could be

for (Fact& fact : *facts) {                // Non-const ref
    fact_queue.push(std::move(fact));      // Move
}

Perhaps this one would be even better, but it requires some testing (which I cannot do at the moment) while the suggested change is 100% risk free.

@henkwiedig henkwiedig merged commit 32df4d9 into OpenIPC:master Jan 6, 2026
6 checks passed
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