Re: [PATCH] [PoC] A simpler find_unique_prefixes() implementation
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Aug 30, 2019, 20:12 UTC
- Message-ID
- <nycvar.QRO.7.76.6.1908302209220.46@tvgsbejvaqbjf.bet>
- In-Reply-To
- <20190828163419.30620-1-szeder.dev@gmail.com>
Hi Gábor,
On Wed, 28 Aug 2019, SZEDER Gábor wrote:
Show 9 quoted lines
> Implement find_unique_prefixes() by sorting the prefix items > lexicographically and then looking for unique prefixes in adjacent > pairs. It's definitely shorter than the current hashmap-based > implementation (101 vs 149 lines), subjectively easier to follow, and > hopefully less buggy (some of the new elements in the test trigger > failure with the hashmap). > > TODO: deal multi-byte caracter sequences, make the test tool more > developer-friendly
Sorry for my late response, I am still trying to catch up with an ever-growing inbox after trying to pretend to be on vacation.
Your argument is a strong one, and I will try to re-roll, folding the functionality to find the unique prefixes into `add-interactive.c` while trying to reuse the already-sorted list for the lookup by prefix.
As to the multi-byte UTF-8 characters: you're right, that code has a bug. The intention was to require only single-byte characters in the prefix, for simplicity.
Thanks, Dscho