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

update the way we glob team files #120

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ashleywillard
Copy link
Contributor

@martinemde says that this change will make these globs a bit faster which is important when you're running this on a large codebase.

Comment on lines +23 to +31
code_team = TeamPlugins::Ownership.for(team)

Dir.glob(code_team.owned_globs).each do |filename|
map[filename] = team
end

# Remove anything that is unowned
TeamPlugins::Ownership.for(team).unowned_globs.each do |glob|
Dir.glob(glob).each do |filename|
map.delete(filename)
end
# Remove anything that is unowned by this team
Dir.glob(code_team.unowned_globs).each do |filename|
map.delete(filename)
Copy link
Collaborator

Choose a reason for hiding this comment

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

this change will make these globs a bit faster

The main reason I'd expect this is that it only tries recursing through the code base once for owned and once for unowned w/ all the glob patterns, as opposed to recursing once per glob.

It might be possible to improve further by doing one giant glob, and using File#fnmatch? to exclude unowned patterns. benchmark-ips + benchmark-memory is super helpful for comparing multiple implementations

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