Skip to content

Commit

Permalink
Lazily calculate should_exclude_patterns in comment script
Browse files Browse the repository at this point in the history
Previously, the values were eagerly filled in which meant that
the comment scaled based on the number of patterns.

Now, the comment command extracts them from the comment.
  • Loading branch information
jsoref committed Jul 21, 2022
1 parent 2c98f6d commit cdf0212
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 2 additions & 0 deletions unknown-words.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2043,6 +2043,7 @@ compare_new_output() {

generate_curl_instructions() {
has_instructions_canary=$(mktemp)
calculate_exclude_patterns
instructions=$(mktemp)
(
echo 'update_files() {'
Expand Down Expand Up @@ -2134,6 +2135,7 @@ fewer_misspellings() {
(
patch_add=1
patch_remove=1
should_exclude_patterns=1
patch_variables $comment_body > $instructions_head
)
. $instructions_head
Expand Down
3 changes: 1 addition & 2 deletions update-state.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ path_to_pattern() {
perl -pe 's/^/^\\Q/;s/$/\\E\$/'
}
calculate_exclude_patterns() {
if [ -z "$should_exclude_patterns" ] && [ -s "$should_exclude_file" ]; then
if [ -z "$should_exclude_patterns" ] && [ -s "$should_exclude_file" ]; then
should_exclude_patterns=$(sort "$should_exclude_file" | path_to_pattern)
fi
}
Expand Down Expand Up @@ -66,7 +66,6 @@ generate_instructions() {
'$q |
strip_lead >> $instructions
fi
calculate_exclude_patterns
if [ -n "$should_exclude_patterns" ]; then
echo "(cat $q$excludes_file$q - 2> /dev/null <<EOF
$should_exclude_patterns
Expand Down

0 comments on commit cdf0212

Please sign in to comment.