-
Notifications
You must be signed in to change notification settings - Fork 702
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
Copy slice before appending #522
Conversation
/cc @mcuadros |
I'm not associated with this repository or this MR, but as a third-party, I can confirm that this patch improved my issue. With upstream go-git in a repo with a 350M folder that was listed in the .gitignore, worktree.Status() returned in ~ 1.6s at best. |
can you provide a test? |
There is no new functionality, so no need for a new unit test. |
subps, err = ReadPatterns(fs, append(path, fi.Name())) | ||
tempPath := make([]string, len(path)) | ||
copy(tempPath, path) | ||
subps, err = ReadPatterns(fs, append(tempPath, fi.Name())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think it would be cleaner to have the copy done by ParsePattern(), the object that takes ownership of the slice. Or in the readIgnoreFile func to share ownership. Here you would still get bugs if calling ReadPatterns incorrectly, e.g:
path := []string{"a", "b"}
ps, _ := ReadPatterns(fs, path)
path[1] = "change" // ps now corrupted
@acumino a test is not only needed for new functionality, a test is useful for fixes like this for multiple reasons include:
|
/close |
Fixes: #500