Skip to content

perf(git-locked): replace sed by cut#1256

Closed
Rudxain wants to merge 1 commit into
tj:mainfrom
Rudxain:perf-locked
Closed

perf(git-locked): replace sed by cut#1256
Rudxain wants to merge 1 commit into
tj:mainfrom
Rudxain:perf-locked

Conversation

@Rudxain
Copy link
Copy Markdown
Contributor

@Rudxain Rudxain commented May 25, 2026

This is a micro-optimization. I did it on my own, but I asked Copilot if it could be improved, it suggested these (not tested):

git ls-files -v | sed -n '/^S /s///p'
git ls-files -v | awk '/^S /{print substr($0,3)}'

@hyperupcall
Copy link
Copy Markdown
Collaborator

Thanks, since this is labeled as an optimization as there any numbers to show it?

@Rudxain
Copy link
Copy Markdown
Contributor Author

Rudxain commented May 30, 2026

any numbers to show it?

no 😅, but here's my reasoning for why it should be faster:

  • sed has to interpret an expression, while cut only has to parse a range
  • sed has to check that the expression matches every line (too much branching), while cut unconditionally slices every line. There could be a speed "tie" if the sed counterpart used the expression s|^..||

@hyperupcall
Copy link
Copy Markdown
Collaborator

hyperupcall commented May 30, 2026

Those could make sense, but I"m not sure if any of those statements are really true without benchmarking and reading the tools' code. Unless there's shown to be a big difference, I think it's best to leave it the way it is. Code churn has a cost

@Rudxain Rudxain deleted the perf-locked branch May 31, 2026 03:54
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