Skip to content

compute: factor out repo lookup

Administrator requested to merge rvt/regexp-replace-result-2 into main

Created by: rvantonder

Stacked on https://github.com/sourcegraph/sourcegraph/pull/26523/files.

Deduplicates a common snippet, factored into a loop.

	repoResolvers := make(map[repoKey]*RepositoryResolver, 10)
	getRepoResolver := func(repoName types.RepoName, rev string) *RepositoryResolver {
		if existing, ok := repoResolvers[repoKey{repoName, rev}]; ok {
			return existing
		}
		resolver := NewRepositoryResolver(db, repoName.ToRepo())
		resolver.RepoMatch.Rev = rev
		repoResolvers[repoKey{repoName, rev}] = resolver
		return resolver
	}

This actually is also more performant, as it is a repo cache over multiple file matches, and previously the cache was just operating on one file match at a time and basically didn't help 🙈

Merge request reports

Loading