diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2020-07-11 20:52:56 -0400 |
---|---|---|
committer | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2020-07-19 11:40:33 -0400 |
commit | 65793a90d75c59d759b32dde01c0dc6a7fb4186c (patch) | |
tree | 1bcb0e1109f89c1010abe6fa234b6b6f3eb03dc4 | |
parent | 420aff590ae5f5ce7b6d807958a10b9fbd8c2594 (diff) | |
download | rneovim-65793a90d75c59d759b32dde01c0dc6a7fb4186c.tar.gz rneovim-65793a90d75c59d759b32dde01c0dc6a7fb4186c.tar.bz2 rneovim-65793a90d75c59d759b32dde01c0dc6a7fb4186c.zip |
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.
https://github.com/vim/vim/commit/408c23b0794540ee3c568a1569f21406c5ed3ab8
-rw-r--r-- | src/nvim/spellfile.c | 80 |
1 files changed, 37 insertions, 43 deletions
diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c index 7bd96b38de..6b9348e55d 100644 --- a/src/nvim/spellfile.c +++ b/src/nvim/spellfile.c @@ -1817,11 +1817,6 @@ static long compress_start = 30000; // memory / SBLOCKSIZE static long compress_inc = 100; // memory / SBLOCKSIZE 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. // Sets "sps_flags". 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]; int flags; int duplicate = 0; + Timestamp last_msg_time = 0; // Open the file. 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; } - // 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) { spin->si_msg_count = 0; - vim_snprintf((char *)message, sizeof(message), - _("line %6d, word %6ld - %s"), - lnum, spin->si_foldwcount + spin->si_keepwcount, w); - msg_start(); - msg_puts_long_attr(message, 0); - msg_clr_eos(); - msg_didout = FALSE; - msg_col = 0; - ui_flush(); + if (os_time() > last_msg_time) { + last_msg_time = os_time(); + vim_snprintf((char *)message, sizeof(message), + _("line %6d, word %6ld - %s"), + lnum, spin->si_foldwcount + spin->si_keepwcount, w); + msg_start(); + msg_puts_long_attr(message, 0); + msg_clr_eos(); + msg_didout = false; + msg_col = 0; + ui_flush(); + } } // 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) { // 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: // 1. When not compressed before (si_compress_cnt == 0): when using // "compress_start" blocks. - // 2. When compressed before and used "used_compress_inc" blocks before - // adding "used_compress_added" words (si_compress_cnt > 1). - // 3. When compressed before, added "used_compress_added" words + // 2. When compressed before and used "compress_inc" blocks before + // adding "compress_added" words (si_compress_cnt > 1). + // 3. When compressed before, added "compress_added" words // (si_compress_cnt == 1) and the number of free nodes drops below the // maximum word length. #ifndef SPELL_COMPRESS_ALLWAYS @@ -3944,11 +3944,11 @@ static int tree_add_word(spellinfo_T *spin, char_u *word, wordnode_T *root, int #endif { // Decrement the block counter. The effect is that we compress again - // when the freed up room has been used and another "used_compress_inc" - // blocks have been allocated. Unless "used_compress_added" words have + // when the freed up room has been used and another "compress_inc" + // blocks have been allocated. Unless "compress_added" words have // been added, then the limit is put back again. - spin->si_blocks_cnt -= used_compress_inc; - spin->si_compress_cnt = used_compress_added; + spin->si_blocks_cnt -= compress_inc; + spin->si_compress_cnt = compress_added; if (spin->si_verbose) { 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 goes fast. But when filling the soundfold word tree // there is no keep-case tree. - wordtree_compress(spin, spin->si_foldroot); - if (affixID >= 0) - wordtree_compress(spin, spin->si_keeproot); + wordtree_compress(spin, spin->si_foldroot, "case-folded"); + if (affixID >= 0) { + wordtree_compress(spin, spin->si_keeproot, "keep-case"); + } } 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. -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; long tot = 0; @@ -4038,13 +4041,6 @@ static void wordtree_compress(spellinfo_T *spin, wordnode_T *root) hash_init(&ht); 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 if (spin->si_verbose || p_verbose > 2) #endif @@ -4056,8 +4052,8 @@ static void wordtree_compress(spellinfo_T *spin, wordnode_T *root) else perc = (tot - n) * 100 / tot; vim_snprintf((char *)IObuff, IOSIZE, - _("Compressed %ld of %ld nodes; %ld (%ld%%) remaining"), - n, tot, tot - n, perc); + _("Compressed %s of %ld nodes; %ld (%ld%%) remaining"), + name, tot, tot - n, perc); spell_message(spin, IObuff); } #ifdef SPELL_PRINTTREE @@ -4158,7 +4154,7 @@ static long node_compress( node->wn_u1.hashkey[5] = NUL; // Check for CTRL-C pressed now and then. - fast_breakcheck(); + veryfast_breakcheck(); return compressed; } @@ -4765,7 +4761,7 @@ static void spell_make_sugfile(spellinfo_T *spin, char_u *wfname) // Compress the soundfold trie. 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. // Make the file name by changing ".spl" to ".sug". @@ -5109,8 +5105,6 @@ mkspell ( ga_init(&spin.si_prefcond, (int)sizeof(char_u *), 50); hash_init(&spin.si_commonwords); 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 // When "fcount" is 1 there is only one file. @@ -5237,9 +5231,9 @@ mkspell ( if (!error && !got_int) { // Combine tails in the tree. spell_message(&spin, (char_u *)_(msg_compressing)); - wordtree_compress(&spin, spin.si_foldroot); - wordtree_compress(&spin, spin.si_keeproot); - wordtree_compress(&spin, spin.si_prefroot); + wordtree_compress(&spin, spin.si_foldroot, "case-folded"); + wordtree_compress(&spin, spin.si_keeproot, "keep-case"); + wordtree_compress(&spin, spin.si_prefroot, "prefixes"); } if (!error && !got_int) { |