]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
*.h: reduce variable scopes
authorEric Wong <e@80x24.org>
Fri, 28 Nov 2025 10:09:45 +0000 (10:09 +0000)
committerEric Wong <e@80x24.org>
Mon, 1 Dec 2025 10:25:10 +0000 (10:25 +0000)
Reducing scopes of local variables improves readability and
should help the compiler make better decisions about register
allocation and reporting possible errors.

lib/PublicInbox/lg2_cfg.h
lib/PublicInbox/xap_helper.h

index f8fa48294759f26b94013d6101590e08dd6ea6c4..deb23001ff077e5297c7f90fdf85696087224788 100644 (file)
 void cfgwr_commit(const char *f, AV *todo)
 {
        I32 i, todo_max = av_len(todo);
-       SV **sv;
        git_config *cfg;
        const git_error *e;
        const char *cmd0, *name, *val, *re;
        int rc = git_config_open_ondisk(&cfg, f);
        STRLEN dlen;
-       AV *cmd;
 
        for (i = 0; rc == GIT_OK && i <= todo_max; i++) {
-               sv = av_fetch(todo, i, 0);
+               SV **sv = av_fetch(todo, i, 0);
+               AV *cmd;
+
                /* leaks on internal bugs: */
                if (!SvROK(*sv)) croak("BUG: not a ref");
                cmd = (AV *)SvRV(*sv);
index 8d153065a6b4a18f21ee3c36ece77294a78564aa..4a45c3aae55fb2b011d4b10abea264e6dc8946ff 100644 (file)
@@ -682,7 +682,6 @@ static void srch_init_extra(struct srch *srch, struct req *req)
 
 static void srch_init(struct req *req)
 {
-       int i;
        struct srch *srch = req->srch;
        const unsigned FLAG_PHRASE = Xapian::QueryParser::FLAG_PHRASE;
        srch->qp_flags = Xapian::QueryParser::FLAG_BOOLEAN |
@@ -697,8 +696,8 @@ static void srch_init(struct req *req)
                shard_nfd = nfd;
        }
        for (int retried = 0; retried < 2; retried++) {
+               int i = 0;
                srch->qp_flags |= FLAG_PHRASE;
-               i = 0;
                try {
                        AUTO_UNLOCK struct open_locks *lk =
                                                        lock_shared_maybe(req);