Re: [vim/vim] u_read_undo(): use a sorted table to swizzle sequence numbers (PR #20942)

Christian Brabandt (Vim Github Repository) <[email protected]> Mon, 10 Aug 2026 13:45:36 -0700
Newsgroups gmane.editors.vim.devel
Message-ID <vim/vim/pull/20942/[email protected]>
chrisbra left a comment (vim/vim#20942)

Hm, I think it may make sense to promote those shorts to long directly? Like this:
```diff
diff --git a/src/undo.c b/src/undo.c
index ed74c27c7..bc17b4b9b 100644
--- a/src/undo.c
+++ b/src/undo.c
@@ -1875,10 +1875,10 @@ u_read_undo(char_u *name, char_u *hash, char_u *orig_name UNUSED)
     long       old_header_seq, new_header_seq, cur_header_seq;
     long       seq_last, seq_cur;
     long       last_save_nr = 0;
-    int                old_idx = -1, new_idx = -1, cur_idx = -1;
+    long       old_idx = -1, new_idx = -1, cur_idx = -1;
     long       num_read_uhps = 0;
     time_t     seq_time;
-    int                i;
+    long       i;
     int                c;
     u_header_T *uhp;
     u_header_T **uhp_table = NULL;
@@ -2187,7 +2187,7 @@ u_read_undo(char_u *name, char_u *hash, char_u *orig_name UNUSED)
 # ifdef U_DEBUG
     for (i = 0; i < num_head; ++i)
        if (uhp_table_used[i] == 0)
-           semsg("uhp_table entry %d not used, leaking memory", i);
+           semsg("uhp_table entry %ld not used, leaking memory", i);
     vim_free(uhp_table_used);
     u_check(TRUE);
 # endif
```

This would also get rid of the change in `semsg` since this is effectively a no-op now and since `old_idx`, `new_idx` `cur_idx` and `i` are used as index into the `uhp_table` it makes sense to use long directly, no?

-- 
Reply to this email directly or view it on GitHub:
https://github.com/vim/vim/pull/20942#issuecomment-5245758064
You are receiving this because you are subscribed to this thread.

Message ID: <vim/vim/pull/20942/[email protected]>

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/vim_dev/vim/vim/pull/20942/c5245758064%40github.com.