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

convert format to use regex replace for shebangs #87

Closed
wants to merge 1 commit into from
Closed

convert format to use regex replace for shebangs #87

wants to merge 1 commit into from

Conversation

pgilad
Copy link
Contributor

@pgilad pgilad commented Jun 25, 2014

indexOf will parse the entire string for #1 while regex for beginning of string will fail-short if first chars don't match.

  • Performance boost (more than 50% on large strings)
  • Cleaner syntax

indexOf will parse the entire string for `#1` while regex for beginning of string will fail-short if first chars don't match.

- Performance boost (more than 50% on large strings)
- Cleaner syntax
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.09%) when pulling 86cf387 on pgilad:patch-1 into 0fb7b16 on rdio:master.

@brettlangdon
Copy link
Contributor

unfortunately the shebang removal/etc happens in more than 1 place. EDIT: have been meaning to look at refactoring it, wouldn't be hurt if you wanted to do it :)

also can you add tests for the edge cases where the previous way falls short?

@pgilad
Copy link
Contributor Author

pgilad commented Jun 25, 2014

Previous way doesn't have a fail case, but if you don't have a shebang in start of string, the indexOf is going to scan the entire string for it.

Just extract what I wrote to an external helper function...

edit I'll do the refactoring... It's going to move to an external lib I guess

@brettlangdon
Copy link
Contributor

@pgilad ah, yes you are right... it does. :( silly me

@pgilad pgilad closed this Jun 25, 2014
@pgilad pgilad deleted the patch-1 branch June 25, 2014 22:01
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.

None yet

3 participants