From: Jeff King Date: Fri, 15 May 2026 03:53:39 GMT Subject: Re: [PATCH 1/4] strbuf: add strbuf_add_uint() Message-ID: <20260515035339.GA75627@coredump.intra.peff.net> In-Reply-To: On Thu, May 14, 2026 at 01:09:24PM +0200, René Scharfe wrote: > > And btw, one final thing to look at if you are interested in > > micro-optimizing strbufs: using intrinsics for overflow detection. > > > > Right now we use unsigned_add_overflows(), and then do the actual add. > > Using __builtin_add_overflow() might be faster. > Curious. Clang and GCC emit the same instructions for our > unsigned_add_overflows() vs. __builtin_add_overflow() on x64, but clang > on ARM64 fails to elide the comparison: https://godbolt.org/z/91d35KofM Ah, neat. I always assumed there was low-hanging fruit to pick here, but it sounds like the compiler is (usually) more clever than I expected. -Peff