Re: [PATCH v2 2/4] string-list: replace negative index encoding with "exact_match" parameter
- From
shejialuo <shejialuo@gmail.com>
- Date
- Oct 5, 2025, 13:31 UTC
- Message-ID
- <aOJzQ1cnUr3WhTSF@ArchLinux>
- In-Reply-To
- <aNJW_z-BD1eDttec@pks.im>
On Tue, Sep 23, 2025 at 10:14:55AM +0200, Patrick Steinhardt wrote:
Show 12 quoted lines
> On Wed, Sep 17, 2025 at 05:19:54PM +0800, shejialuo wrote: > > We would return negative index to indicate exact match by converting the > > original positive index to be "-1 - index" in > > "string_list_find_insert_index", which requires callers to decode this > > information. This approach has several limitations: > > > > 1. It prevents us from using the full range of size_t, which is > > necessary for large string list. > > I guess this is more of a theoretical concern. We probably wouldn't > handle it well when our list had 2 billion entries anyway. >
That's right. From the discussion, I would update the commit message in the next version.
Show 9 quoted lines
> > 2. Using int for indices while other parts of the codebase use size_t > > creates signed comparison warnings when these values are compared. > > Yup. > > I think that the required juggling around negative indices is another > factor here. It's somewhat weird, and while existing callers all handle > this correct I think that it makes for a suboptimal interface. >
That's right, I would improve this in the next version.
Thanks, Jialuo