Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qXkDU-0071Lb-Vo for pgsql-hackers@arkaria.postgresql.org; Sun, 20 Aug 2023 15:19:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qXkDT-005pHp-DF for pgsql-hackers@arkaria.postgresql.org; Sun, 20 Aug 2023 15:19:47 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qXkDS-005pHg-W3 for pgsql-hackers@lists.postgresql.org; Sun, 20 Aug 2023 15:19:47 +0000 Received: from mail-qv1-xf35.google.com ([2607:f8b0:4864:20::f35]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qXkDN-001Aw6-2B for pgsql-hackers@postgresql.org; Sun, 20 Aug 2023 15:19:45 +0000 Received: by mail-qv1-xf35.google.com with SMTP id 6a1803df08f44-64c5f5d6f04so10604096d6.3 for ; Sun, 20 Aug 2023 08:19:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692544780; x=1693149580; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=xCwTKFgDAdkgD5W0A+/EW/UcNp4frGo9l+r2GED7iLk=; b=gl5EoRbNAnK4S+9gDKTlAvOMhBWRvLBAkYyaNCuIqDKfmlIMmCC4FvkW53tHx8x45d UNbzFtviSUfQrWkGK1qx2Wu/SKTDbqT5JsFyxZTL+fY7C5+4RWT7qPF0JiNmq+WshD1z 6XrpIq2VBjkN8wEMWdHnLIW4+J1FWBiRY7jKUJK32xps8UvOabhb4K+uVmkiWPVmkpfS wmTrN09Kq0qF1wuKc63I+I16FypRdNPvvXCsYhJ2DfT4GYjs1ugssG/X7J0NXXlaoD84 Wte5daa+BOohNK5XZOWkxLlxsZRz6a35Q9b9gupA9F5spU8aefR2UoaDGVGJJNuyNNK8 bFvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692544780; x=1693149580; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=xCwTKFgDAdkgD5W0A+/EW/UcNp4frGo9l+r2GED7iLk=; b=Wo9y/lfTlOVNE/S+/GHxbPFxETEnkbDvufVRecurfzAwjzkKN8ZWzZfHN4DCcnYCma mEKUS03BEzreSKQKNaIaZTOZth7dtpKiv7Fadln99vhol1aBz9pTI3J4NKIhGcPUbtEe XpovZw8svTBky/zZayw27EtdaOHmTJlwPt6dq/idurpZtE5xPVrhRsTNtqmG1HeZCVbQ BhxbyGTyEomnWp1kYs56EdZDmdFuFjCJH8Lx3Hf//ULonz3HOQwYgQoOpC60xatg1L3W VFWCb4zRNQ+4j7vHfwKLRxxjKNgQwkZNTqjTZxy0a5+coOcn+aXLpYQbY6y8o68QT64v CsCw== X-Gm-Message-State: AOJu0YweGVtZUBi40NjtfgvdH12X/qJ6nYA4HlzAOEJGLmvaSF+zMVBd MVf9e02x5d1FkguiIDCMRMg= X-Google-Smtp-Source: AGHT+IHBHu4EruNzG0HXz0upJPCteY6K/SzcvwTGjwm5CTnwqlRb/8EHkpvotvHUc3sxK0YnPvt8DQ== X-Received: by 2002:a0c:dc12:0:b0:64b:fdf0:48a3 with SMTP id s18-20020a0cdc12000000b0064bfdf048a3mr4831576qvk.10.1692544780172; Sun, 20 Aug 2023 08:19:40 -0700 (PDT) Received: from nathanxps13 (rrcs-70-62-147-148.central.biz.rr.com. [70.62.147.148]) by smtp.gmail.com with ESMTPSA id y18-20020a0ce052000000b0062439f05b87sm2237907qvk.45.2023.08.20.08.19.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Aug 2023 08:19:39 -0700 (PDT) Date: Sun, 20 Aug 2023 08:19:37 -0700 From: Nathan Bossart To: John Naylor Cc: Kirk Wolak , Peter Eisentraut , Eric Radman , pgsql-hackers@postgresql.org Subject: Re: [PATCH] Add function to_oct Message-ID: <20230820151937.GA290672@nathanxps13> References: <20230726001656.GC2992317@nathanxps13> <20230726032917.GA3151386@nathanxps13> <20230815041129.GB2294364@nathanxps13> <20230815171715.GA2312399@nathanxps13> <20230816142410.GA2651383@nathanxps13> <20230817152628.GA3148583@nathanxps13> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sat, Aug 19, 2023 at 11:41:56AM +0700, John Naylor wrote: > This looks nicer, but still doesn't save the starting pointer, and so needs > to lug around that big honking macro. This is what I mean: > > static inline text * > convert_to_base(uint64 value, int base) > { > const char *digits = "0123456789abcdef"; > /* We size the buffer for to_binary's longest possible return value. */ > char buf[sizeof(uint64) * BITS_PER_BYTE]; > char * const end = buf + sizeof(buf); > char *ptr = end; > > Assert(base > 1); > Assert(base <= 16); > > do > { > *--ptr = digits[value % base]; > value /= base; > } while (ptr > buf && value); > > return cstring_to_text_with_len(ptr, end - ptr); > } I will use this in v8. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com