unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: pierre.techoueyres@free.fr (Pierre Téchoueyres)
To: Noam Postavsky <npostavs@gmail.com>
Cc: Eli Zaretskii <eliz@gnu.org>, Emacs developers <emacs-devel@gnu.org>
Subject: Re: Add support for base64url variant
Date: Thu, 23 May 2019 21:32:31 +0200	[thread overview]
Message-ID: <874l5l6k6o.fsf@killashandra.ballybran.fr> (raw)
In-Reply-To: <CAM-tV-_Y5smRx3G1=fFW5Cvuzfo1nEqm1ePtYTy5Tgb-=b94rw@mail.gmail.com> (Noam Postavsky's message of "Thu, 23 May 2019 14:45:51 -0400")

Noam Postavsky <npostavs@gmail.com> writes:

> On Thu, 23 May 2019 at 13:51, Pierre Téchoueyres
> <pierre.techoueyres@free.fr> wrote:
>>
>> Eli Zaretskii <eliz@gnu.org> 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 "=" 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 = (url_variant) ? base64url_value_to_char : 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.



  reply	other threads:[~2019-05-23 19:32 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-21 22:32 Add support for base64url variant Pierre Téchoueyres
2019-05-22  7:43 ` Eli Zaretskii
2019-05-22  9:25   ` Pierre Téchoueyres
2019-05-22  9:50     ` Eli Zaretskii
2019-05-23 17:51       ` Pierre Téchoueyres
2019-05-23 18:45         ` Noam Postavsky
2019-05-23 19:32           ` Pierre Téchoueyres [this message]
2019-05-23 18:58         ` Eli Zaretskii
2019-05-23 18:50 ` Eli Zaretskii
2019-05-23 19:37   ` Pierre Téchoueyres
2019-05-23 19:51     ` Eli Zaretskii
2019-05-27 20:30       ` Pierre Téchoueyres
2019-06-07 21:04         ` Pierre Téchoueyres
2019-06-08  5:52           ` Eli Zaretskii
2019-06-08  8:18         ` Eli Zaretskii
2019-06-11 18:36           ` Pierre Téchoueyres
2019-06-11 18:42             ` Eli Zaretskii
2019-06-11 18:47               ` Achim Gratz
2019-06-11 20:14                 ` Richard Copley
2019-06-12 15:34                   ` Eli Zaretskii
2019-06-12  6:50                 ` Stefan Monnier
2019-06-12 19:24                   ` Achim Gratz
2019-06-12 21:50                     ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874l5l6k6o.fsf@killashandra.ballybran.fr \
    --to=pierre.techoueyres@free.fr \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=npostavs@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).