Skip to content

Optimize Mapper::findBy variants: reserve + emplace_back + optional move #2510

Merged
an-tao merged 1 commit intodrogonframework:masterfrom
kaili302:mapper_findby_optimization
May 6, 2026
Merged

Optimize Mapper::findBy variants: reserve + emplace_back + optional move #2510
an-tao merged 1 commit intodrogonframework:masterfrom
kaili302:mapper_findby_optimization

Conversation

@kaili302
Copy link
Copy Markdown
Contributor

@kaili302 kaili302 commented May 5, 2026

No public API change

What's changed:

  • ret.reserve(r.size()) before the row loop. Result::size() is noexcept and O(1), so this is essentially free and eliminates
  • emplace_back(row) instead of push_back(T(row)) as a tiny optimization
  • prom->set_value(std::move(ret)) in findFutureBy. ret is a non-const, so without std::move the whole vector was being copy-constructed into the promise

Test plan

Existing ORM tests still pass

@an-tao an-tao merged commit 22e165d into drogonframework:master May 6, 2026
34 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