Skip to content

perf: Look into optimizing memory allocations within apply_diff() #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Tracked by #35
neoncitylights opened this issue Jan 5, 2023 · 2 comments
Open
Tracked by #35
Assignees
Labels
lvl-1-easy Easy-ranking issue p1-low Priority 1: Generally no one plans to work on the task, but it would be nice if someone decides to. t-performance Issue relating to performance, like optimizations or benchmarks

Comments

@neoncitylights
Copy link
Contributor

Because String.insert() and String.remove() are both O(n) (linear) operations, it'd be useful to look into reducing the number of internal calls to both of these methods. There is one way I'm thinking of at the moment, which is to look for series of length-shifting operations.

We can keep track of the last diff operation, and compare it to the current one.

  • Inserts: reduce a series of push calls into a single push_str() call
  • Deletes: reduce a series of remove calls into a single remove() call
@neoncitylights neoncitylights added lvl-1-easy Easy-ranking issue p1-low Priority 1: Generally no one plans to work on the task, but it would be nice if someone decides to. t-performance Issue relating to performance, like optimizations or benchmarks labels Jan 5, 2023
@neoncitylights neoncitylights self-assigned this Jan 5, 2023
@neoncitylights
Copy link
Contributor Author

@notalfredo wanna try this?

@notalfredo
Copy link
Member

@notalfredo wanna try this?

sure I can try it out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lvl-1-easy Easy-ranking issue p1-low Priority 1: Generally no one plans to work on the task, but it would be nice if someone decides to. t-performance Issue relating to performance, like optimizations or benchmarks
Projects
None yet
Development

No branches or pull requests

2 participants