vim-patch:8.2.0895: :mkspell output does not mention the tree type

Problem:    :mkspell output does not mention the tree type.
Solution:   Back out increasing the limits, it has no effect.  Mention the
            tree being compressed.  Only give a message once per second.
408c23b079
This commit is contained in:
Jan Edmund Lazo
2020-07-11 20:52:56 -04:00
parent 420aff590a
commit 65793a90d7

View File

@@ -1817,11 +1817,6 @@ static long compress_start = 30000; // memory / SBLOCKSIZE
static long compress_inc = 100; // memory / SBLOCKSIZE static long compress_inc = 100; // memory / SBLOCKSIZE
static long compress_added = 500000; // word count static long compress_added = 500000; // word count
// Actually used values. These can change if compression doesn't result in
// reducing the size.
static long used_compress_inc;
static long used_compress_added;
// Check the 'mkspellmem' option. Return FAIL if it's wrong. // Check the 'mkspellmem' option. Return FAIL if it's wrong.
// Sets "sps_flags". // Sets "sps_flags".
int spell_check_msm(void) int spell_check_msm(void)
@@ -3022,6 +3017,7 @@ static int spell_read_dic(spellinfo_T *spin, char_u *fname, afffile_T *affile)
char_u message[MAXLINELEN + MAXWLEN]; char_u message[MAXLINELEN + MAXWLEN];
int flags; int flags;
int duplicate = 0; int duplicate = 0;
Timestamp last_msg_time = 0;
// Open the file. // Open the file.
fd = os_fopen((char *)fname, "r"); fd = os_fopen((char *)fname, "r");
@@ -3097,18 +3093,22 @@ static int spell_read_dic(spellinfo_T *spin, char_u *fname, afffile_T *affile)
continue; continue;
} }
// This takes time, print a message every 10000 words. // This takes time, print a message every 10000 words, but not more
// often than once per second.
if (spin->si_verbose && spin->si_msg_count > 10000) { if (spin->si_verbose && spin->si_msg_count > 10000) {
spin->si_msg_count = 0; spin->si_msg_count = 0;
vim_snprintf((char *)message, sizeof(message), if (os_time() > last_msg_time) {
_("line %6d, word %6ld - %s"), last_msg_time = os_time();
lnum, spin->si_foldwcount + spin->si_keepwcount, w); vim_snprintf((char *)message, sizeof(message),
msg_start(); _("line %6d, word %6ld - %s"),
msg_puts_long_attr(message, 0); lnum, spin->si_foldwcount + spin->si_keepwcount, w);
msg_clr_eos(); msg_start();
msg_didout = FALSE; msg_puts_long_attr(message, 0);
msg_col = 0; msg_clr_eos();
ui_flush(); msg_didout = false;
msg_col = 0;
ui_flush();
}
} }
// Store the word in the hashtable to be able to find duplicates. // Store the word in the hashtable to be able to find duplicates.
@@ -3923,7 +3923,7 @@ static int tree_add_word(spellinfo_T *spin, char_u *word, wordnode_T *root, int
if (spin->si_compress_cnt > 1) { if (spin->si_compress_cnt > 1) {
if (--spin->si_compress_cnt == 1) { if (--spin->si_compress_cnt == 1) {
// Did enough words to lower the block count limit. // Did enough words to lower the block count limit.
spin->si_blocks_cnt += used_compress_inc; spin->si_blocks_cnt += compress_inc;
} }
} }
@@ -3932,9 +3932,9 @@ static int tree_add_word(spellinfo_T *spin, char_u *word, wordnode_T *root, int
// need that room, thus only compress in the following situations: // need that room, thus only compress in the following situations:
// 1. When not compressed before (si_compress_cnt == 0): when using // 1. When not compressed before (si_compress_cnt == 0): when using
// "compress_start" blocks. // "compress_start" blocks.
// 2. When compressed before and used "used_compress_inc" blocks before // 2. When compressed before and used "compress_inc" blocks before
// adding "used_compress_added" words (si_compress_cnt > 1). // adding "compress_added" words (si_compress_cnt > 1).
// 3. When compressed before, added "used_compress_added" words // 3. When compressed before, added "compress_added" words
// (si_compress_cnt == 1) and the number of free nodes drops below the // (si_compress_cnt == 1) and the number of free nodes drops below the
// maximum word length. // maximum word length.
#ifndef SPELL_COMPRESS_ALLWAYS #ifndef SPELL_COMPRESS_ALLWAYS
@@ -3944,11 +3944,11 @@ static int tree_add_word(spellinfo_T *spin, char_u *word, wordnode_T *root, int
#endif #endif
{ {
// Decrement the block counter. The effect is that we compress again // Decrement the block counter. The effect is that we compress again
// when the freed up room has been used and another "used_compress_inc" // when the freed up room has been used and another "compress_inc"
// blocks have been allocated. Unless "used_compress_added" words have // blocks have been allocated. Unless "compress_added" words have
// been added, then the limit is put back again. // been added, then the limit is put back again.
spin->si_blocks_cnt -= used_compress_inc; spin->si_blocks_cnt -= compress_inc;
spin->si_compress_cnt = used_compress_added; spin->si_compress_cnt = compress_added;
if (spin->si_verbose) { if (spin->si_verbose) {
msg_start(); msg_start();
@@ -3963,9 +3963,10 @@ static int tree_add_word(spellinfo_T *spin, char_u *word, wordnode_T *root, int
// compression useful, or one of them is small, which means // compression useful, or one of them is small, which means
// compression goes fast. But when filling the soundfold word tree // compression goes fast. But when filling the soundfold word tree
// there is no keep-case tree. // there is no keep-case tree.
wordtree_compress(spin, spin->si_foldroot); wordtree_compress(spin, spin->si_foldroot, "case-folded");
if (affixID >= 0) if (affixID >= 0) {
wordtree_compress(spin, spin->si_keeproot); wordtree_compress(spin, spin->si_keeproot, "keep-case");
}
} }
return OK; return OK;
@@ -4026,7 +4027,9 @@ static void free_wordnode(spellinfo_T *spin, wordnode_T *n)
} }
// Compress a tree: find tails that are identical and can be shared. // Compress a tree: find tails that are identical and can be shared.
static void wordtree_compress(spellinfo_T *spin, wordnode_T *root) static void wordtree_compress(spellinfo_T *spin, wordnode_T *root,
const char *name)
FUNC_ATTR_NONNULL_ALL
{ {
hashtab_T ht; hashtab_T ht;
long tot = 0; long tot = 0;
@@ -4038,13 +4041,6 @@ static void wordtree_compress(spellinfo_T *spin, wordnode_T *root)
hash_init(&ht); hash_init(&ht);
const long n = node_compress(spin, root->wn_sibling, &ht, &tot); const long n = node_compress(spin, root->wn_sibling, &ht, &tot);
if (tot == 0) {
// Compression did not have effect. Increase the limits by 20% to
// avoid wasting time on compression, memory will be used anyway.
used_compress_inc += used_compress_inc / 5;
used_compress_added += used_compress_added / 5;
}
#ifndef SPELL_PRINTTREE #ifndef SPELL_PRINTTREE
if (spin->si_verbose || p_verbose > 2) if (spin->si_verbose || p_verbose > 2)
#endif #endif
@@ -4056,8 +4052,8 @@ static void wordtree_compress(spellinfo_T *spin, wordnode_T *root)
else else
perc = (tot - n) * 100 / tot; perc = (tot - n) * 100 / tot;
vim_snprintf((char *)IObuff, IOSIZE, vim_snprintf((char *)IObuff, IOSIZE,
_("Compressed %ld of %ld nodes; %ld (%ld%%) remaining"), _("Compressed %s of %ld nodes; %ld (%ld%%) remaining"),
n, tot, tot - n, perc); name, tot, tot - n, perc);
spell_message(spin, IObuff); spell_message(spin, IObuff);
} }
#ifdef SPELL_PRINTTREE #ifdef SPELL_PRINTTREE
@@ -4158,7 +4154,7 @@ static long node_compress(
node->wn_u1.hashkey[5] = NUL; node->wn_u1.hashkey[5] = NUL;
// Check for CTRL-C pressed now and then. // Check for CTRL-C pressed now and then.
fast_breakcheck(); veryfast_breakcheck();
return compressed; return compressed;
} }
@@ -4765,7 +4761,7 @@ static void spell_make_sugfile(spellinfo_T *spin, char_u *wfname)
// Compress the soundfold trie. // Compress the soundfold trie.
spell_message(spin, (char_u *)_(msg_compressing)); spell_message(spin, (char_u *)_(msg_compressing));
wordtree_compress(spin, spin->si_foldroot); wordtree_compress(spin, spin->si_foldroot, "case-folded");
// Write the .sug file. // Write the .sug file.
// Make the file name by changing ".spl" to ".sug". // Make the file name by changing ".spl" to ".sug".
@@ -5109,8 +5105,6 @@ mkspell (
ga_init(&spin.si_prefcond, (int)sizeof(char_u *), 50); ga_init(&spin.si_prefcond, (int)sizeof(char_u *), 50);
hash_init(&spin.si_commonwords); hash_init(&spin.si_commonwords);
spin.si_newcompID = 127; // start compound ID at first maximum spin.si_newcompID = 127; // start compound ID at first maximum
used_compress_inc = compress_inc;
used_compress_added = compress_added;
// default: fnames[0] is output file, following are input files // default: fnames[0] is output file, following are input files
// When "fcount" is 1 there is only one file. // When "fcount" is 1 there is only one file.
@@ -5237,9 +5231,9 @@ mkspell (
if (!error && !got_int) { if (!error && !got_int) {
// Combine tails in the tree. // Combine tails in the tree.
spell_message(&spin, (char_u *)_(msg_compressing)); spell_message(&spin, (char_u *)_(msg_compressing));
wordtree_compress(&spin, spin.si_foldroot); wordtree_compress(&spin, spin.si_foldroot, "case-folded");
wordtree_compress(&spin, spin.si_keeproot); wordtree_compress(&spin, spin.si_keeproot, "keep-case");
wordtree_compress(&spin, spin.si_prefroot); wordtree_compress(&spin, spin.si_prefroot, "prefixes");
} }
if (!error && !got_int) { if (!error && !got_int) {