Skip to content

Optimisations#1133

Open
dimbleby wants to merge 2 commits intotoml-rs:mainfrom
dimbleby:micro-optimisations
Open

Optimisations#1133
dimbleby wants to merge 2 commits intotoml-rs:mainfrom
dimbleby:micro-optimisations

Conversation

@dimbleby
Copy link
Copy Markdown
Contributor

@dimbleby dimbleby commented Mar 30, 2026

A couple of small optimisations:

  • avoid unnecessary path cloning in get_values()
  • avoid needlessly collecting one already-owned Vec into another

The second seems easy, the first is maybe a little bit on the clever side for modest gain.

If you want both, or neither, thats easy: merge or reject. If you want one but not the other let me know.

@dimbleby dimbleby force-pushed the micro-optimisations branch 2 times, most recently from eb37e26 to 1be22da Compare March 30, 2026 10:26
pub(crate) fn append_values<'s>(
&'s self,
parent: &[&'s Key],
parent: &mut Vec<&'s Key>,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we do this, it is unusual enough that this will need documentation

dimbleby and others added 2 commits March 31, 2026 00:36
Use push/pop on a shared Vec instead of cloning the
parent path for every child in append_values() and
append_all_values(). Paths are now only cloned when
storing leaf values in the result.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
values.values is already a Vec<Item>, so
into_iter().collect::<Vec<_>>() just copies it
needlessly. Use the owned Vec directly.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dimbleby dimbleby force-pushed the micro-optimisations branch from 1be22da to 4de79db Compare March 30, 2026 23:37
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