From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: pierre.techoueyres@free.fr (Pierre =?utf-8?Q?T=C3=A9choueyres?=) Newsgroups: gmane.emacs.devel Subject: Re: Add support for base64url variant Date: Thu, 23 May 2019 21:32:31 +0200 Message-ID: <874l5l6k6o.fsf@killashandra.ballybran.fr> References: <87pnobiglo.fsf@killashandra.ballybran.fr> <837eaj7x37.fsf@gnu.org> <3b0dc49f9831435178dc1b64d6a2f5c7@free.fr> <83zhne7r8d.fsf@gnu.org> <87blzt6ovv.fsf@killashandra.ballybran.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="125572"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2.50 (gnu/linux) Cc: Eli Zaretskii , Emacs developers To: Noam Postavsky Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu May 23 21:33:31 2019 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hTtT0-000WSq-V5 for ged-emacs-devel@m.gmane.org; Thu, 23 May 2019 21:33:31 +0200 Original-Received: from localhost ([127.0.0.1]:42342 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTtSz-0002Cv-SP for ged-emacs-devel@m.gmane.org; Thu, 23 May 2019 15:33:29 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:52082) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTtSA-0002Cq-LH for emacs-devel@gnu.org; Thu, 23 May 2019 15:32:39 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hTtS9-0005AP-K3 for emacs-devel@gnu.org; Thu, 23 May 2019 15:32:38 -0400 Original-Received: from smtp4-g21.free.fr ([212.27.42.4]:31152) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hTtS8-00058k-47; Thu, 23 May 2019 15:32:36 -0400 Original-Received: from killashandra.ballybran.fr.free.fr (unknown [IPv6:2a01:e0a:1e2:f8b0:9cc3:35bf:aa81:ccf7]) by smtp4-g21.free.fr (Postfix) with ESMTPS id 0FD8E19F59E; Thu, 23 May 2019 21:32:31 +0200 (CEST) In-Reply-To: (Noam Postavsky's message of "Thu, 23 May 2019 14:45:51 -0400") X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 212.27.42.4 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:236945 Archived-At: Noam Postavsky writes: > On Thu, 23 May 2019 at 13:51, Pierre T=C3=A9choueyres > wrote: >> >> Eli Zaretskii writes: >> >> >> ... >> >> I would like to have some discussion on how to improve some points : >> >> - Is adding parameter to existing functions the way to go or is it >> >> better to add new ones for base64url >> > >> > I think an optional argument will be fine. >> >> Except here I've added two, and one that doesn't really mean anything if >> the second isn't set. ie. you should not (at least without breaking the >> RFC) generate an base64 string without padding. At first many >> parameters seemed to me a good thing : limitted patch and flexibility. >> But now I'm no more sure ... > > You could leave out the NO-PAD argument, it's easy enough for the > calling Lisp code to delete a couple of "=3D" chars if really needed. > This could be an option ... but I do see this as ugly adding characters on one side to remove them from the other. Maybe it could be better to split the functions then ? What about (base64-encode-string STRING &optional NO-LINE-BREAK) (base64url-encode-string STRING &optional NO-PAD) and (base64-encode-region BEG END &optional NO-LINE-BREAK) (base64url-encode-region BEG END &optional NO-PAD) >> I would also bring your attention on the part where I dynamically assign >> pointers on specialized arrays for encoding (resp. decoding). >> >> ex: line 244 of patch >> >> char const *b64_value_to_char =3D (url_variant) ? base64url_value_to_cha= r : base64_value_to_char; >> >> >> Before my change there were static const, so I suppose compiler could >> have inlined them or at least stored on some cache. But now ... >> So I'm a little scarried by the possible lost of performance. If anyone >> has some hint on how I could benchmark this > > I doubt it will have a measurable impact on performance. And even if > it did have some very tiny effect, what would you do about it? > Duplicate the whole encoding function, just to avoid a dynamic choice > of array? The difference would have to be pretty drastic to be worth > that, IMO. Thanks, I hoped for something like your answer.