Skip to content

Reduce the number of scope expansions during overlapped file detection in Version::GetOverlappingInputs #1268

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

caelumable
Copy link

if (begin != nullptr && user_cmp->Compare(file_start, user_begin) < 0) {
  user_begin = file_start;
  inputs->clear();
  i = 0;
 } else if (end != nullptr &&
           user_cmp->Compare(file_limit, user_end) > 0) {
  user_end = file_limit;
  inputs->clear();
  i = 0;
}

If the range of user_begin and user_end is [c, d] while the range of file_start and file_limit is [a, g], this would result in two scope expansions: first expanding user_begin and user_end to [a, d], and then further expanding them to [a, g], thereby increasing the number of loop iterations.

Removing this else clause would allow completing the scope expansion in a single step by directly adjusting user_begin and user_end to [a, g].

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.

1 participant