Skip to content
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

Performance improvements #36

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

telemenar
Copy link

This makes a number of performance improvements avoiding largely copying and additional comparison.

The two most significant pieces are:

  • re-arranging to avoid needing to allocate memory for splitslash
  • switching to an enum for the mode

Chris Pride added 5 commits August 10, 2015 12:19
Using the enum rather than string comparisons as the match progresses
should save cycles.
- Don't use strtok -- we only care about the last token anyway which
  means we can just find where that token begins.
- If we are scanning rather than tokenizing we can look for both '\\'
  and '/' so we don't need to modify the string.
- If we don't modify the string we don't need to make a copy.
pch = strtok(NULL, "/");
char *fname = line;
char *scan = fname;
while (scan != '\0')
Copy link

@ptzz ptzz Dec 9, 2017

Choose a reason for hiding this comment

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

Crashes for me. I think it should be while (*scan != '\0').

@ptzz ptzz mentioned this pull request Dec 9, 2017
@ptzz
Copy link

ptzz commented Dec 9, 2017

@telemenar This is good stuff, thanks! I forked your repo to https://github.com/ptzz/ctrlp-cmatcher and optimised further. Managed to cut the processing time by ~80% for large input. The delay is not really noticeable now for 100k files on a 2012 Macbook.

The trick was to use partial sort and only sort the items visible on screen.

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