Skip to content

Commit

Permalink
Add good_words to project dict more efficiently (#1261)
Browse files Browse the repository at this point in the history
Previously it saved the dictionary after reading each word from
the `good_words.txt`. Now it reads them all, then does a single
save at the end.

Fixes #1255
  • Loading branch information
windymilla authored Oct 14, 2023
1 parent 9d53496 commit d036742
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/lib/Guiguts/SpellCheck.pm
Original file line number Diff line number Diff line change
Expand Up @@ -226,18 +226,16 @@ sub spelladdword {
}

#
# Add a word to the project dictionary
# Optional second argument if it's a bad word
# Add a single word to the project dictionary and save it - slow if used for bulk additions
sub spellmyaddword {
my $textwindow = $::textwindow;
my $term = shift;
my $bad = shift;
unless ($term) {
::soundbell();
return;
}
return if $term =~ /^\s*$/;
( $bad ? $::projectbadwords{$term} : $::projectdict{$term} ) = '';
$::projectdict{$term} = '';
spellsaveprojdict();
}

Expand Down Expand Up @@ -502,7 +500,7 @@ sub spelladdgoodwords {
while ( my $line = <$fh> ) {
$line =~ s/\s+$//;
next if $line eq '';
spellmyaddword($line);
$::projectdict{$line} = '';
}
close($fh);

Expand All @@ -511,10 +509,11 @@ sub spelladdgoodwords {
while ( my $line = <$fh> ) {
$line =~ s/\s+$//;
next if $line eq '';
spellmyaddword( $line, "bad" );
$::projectbadwords{$line} = '';
}
close($fh);
}
spellsaveprojdict();
::unbusy();
} else {
::warnerror("Could not open good_words.txt");
Expand Down

0 comments on commit d036742

Please sign in to comment.