From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.6 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id 1A87E1F4B4 for ; Sat, 23 Jan 2021 21:12:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726264AbhAWVLh (ORCPT ); Sat, 23 Jan 2021 16:11:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725922AbhAWVLd (ORCPT ); Sat, 23 Jan 2021 16:11:33 -0500 Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 238B8C0613D6 for ; Sat, 23 Jan 2021 13:10:53 -0800 (PST) Received: by mail-oi1-x22f.google.com with SMTP id m13so2412514oig.8 for ; Sat, 23 Jan 2021 13:10:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xGdG3VCnJ2pFc0vyqL72SJJsTj2OLPI6dnF7J3otsMA=; b=agyP8oInwnVFz1mCtcP6a9NBzpQL+dwWYYWPHhbokFUL11QYrQURv+y4TZew9tTIeB Pize3wjrblrK4iDdhtHGGNyK77d7AWbk386fP7zJuTk02NGqPUzdPBO03ck31ALD5CfU dzXWZHH9Tl21fXL3KmyoAbRFaVJu1VttVgEH96ic4oiSh9Nw7BTeNldRmnZSnoFQsmke PDvN0YN+uNMTBAt0/rsvR9j7ZKXXayhx/rpz3RQJ4vqzDWLLnkzVIR7bDPuWF8Q5Nhxn +IMNPxfg3PtWHymdPXxZDCkjxEB4fVgafBd19mIVT/lK0gBvhuZLN+0n3VmR1ptIku1H WFVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xGdG3VCnJ2pFc0vyqL72SJJsTj2OLPI6dnF7J3otsMA=; b=avnPOYtYLK2AQiJW1O9adS+I5lKugmE3q1xmkA0NRbWWNp7III12bydws/Luf6QN41 r8xmLEufIz5t9W4hnBtQBadSNJSg6FAwNtHTxVALsyApgb+wU7k0DtCMbwWliMEVW921 N1hJxiFiUxBUraU5zv2/KU38k3wWEI1mSrv1Tf+5u2inAWaBTlKGVTrDg8qiv9O6zK7s 5Lyn6Jd0W4aKy6Pl2mcwA9Og+Y8lkffPSRpdHv1800yk2PVHLGloM/NPOsofeSAsB1/e 8H1Jt1Up1saKiyYjw68vLVY2kIxy0OkvOLmMF3iA+BcXeZI3hDI3tw4/ht3zOZQqiytC XGfw== X-Gm-Message-State: AOAM532vKUjxGfK5uw/82mxr9hTqQONTbAyadVPY1tXg2wWw+ywcrFh/ ZYnhq2OsX5gmctt6wtgnhf5VySKGT9zykuWZNK8= X-Google-Smtp-Source: ABdhPJxnaFpYEv+rWN2eKvNYxztE7vV5K8SV136Ja+wVAJq62IMjHc3DkLER1jBiQGehGFl6NERQOZHWUKQxwxfke+k= X-Received: by 2002:aca:a816:: with SMTP id r22mr2246218oie.31.1611436252446; Sat, 23 Jan 2021 13:10:52 -0800 (PST) MIME-Version: 1.0 References: <1b8b56800948339c0e0387555698bdfdc80a19ad.1611431900.git.gitgitgadget@gmail.com> In-Reply-To: From: Elijah Newren Date: Sat, 23 Jan 2021 13:10:41 -0800 Message-ID: Subject: Re: [PATCH v3 2/9] cache-tree: simplify verify_cache() prototype To: Derrick Stolee Cc: Derrick Stolee via GitGitGadget , Git Mailing List , Junio C Hamano , Derrick Stolee , Derrick Stolee Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Sat, Jan 23, 2021 at 1:02 PM Derrick Stolee wrote: > > On 1/23/2021 3:24 PM, Elijah Newren wrote: > > On Sat, Jan 23, 2021 at 11:58 AM Derrick Stolee via GitGitGadget > > wrote: > >> - for (i = 0; i < entries - 1; i++) { > >> + for (i = 0; i + 1 < istate->cache_nr; i++) { > >> /* path/file always comes after path because of the way > >> * the cache is sorted. Also path can appear only once, > >> * which means conflicting one would immediately follow. > >> */ > >> - const struct cache_entry *this_ce = cache[i]; > >> - const struct cache_entry *next_ce = cache[i + 1]; > >> + const struct cache_entry *this_ce = istate->cache[i]; > >> + const struct cache_entry *next_ce = istate->cache[i + 1]; > >> const char *this_name = this_ce->name; > >> const char *next_name = next_ce->name; > >> int this_len = ce_namelen(this_ce); > > Makes sense. Thanks for explaining the i + 1 < istate->cache_nr bit > > in the commit message; made it easier to read through quickly. I'm > > curious if it deserves a comment in the code too, since it does feel > > slightly unusual. > > I would argue that "i + 1 < N" is a more natural way to write this, > because we use "i + 1" as an index, so we want to ensure the index > we are about to use is within range. "i < N - 1" is the backwards > way to write that statement. Oh, right, I think I was reading too quickly and assuming one thing in my head (about what the code was going to do), and forgetting that assumption when I got to the actual code. Sorry about that; I agree with you, so ignore my previous comment.