diff options
| author | Lars Ingebrigtsen <larsi@gnus.org> | 2020-08-24 16:44:24 +0200 |
|---|---|---|
| committer | Lars Ingebrigtsen <larsi@gnus.org> | 2020-08-24 16:44:24 +0200 |
| commit | 88795c52ff13203dda5940ed5defc26ce2c20e5e (patch) | |
| tree | e37715f704e7b8a42ef8cc7e9b440d4927253ef6 /src | |
| parent | 230bddbd78cc86c4520112c4cead2e1ec3cddb77 (diff) | |
| download | emacs-88795c52ff13203dda5940ed5defc26ce2c20e5e.tar.gz | |
Have gnutls_symmetric cache the results from Fgnutls_ciphers
* src/gnutls.c (gnutls_symmetric): Cache the results from
Fgnutls_ciphers, since that function isn't very fast (bug#42998).
(syms_of_gnutls): Initialize cache variable.
Diffstat (limited to 'src')
| -rw-r--r-- | src/gnutls.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/gnutls.c b/src/gnutls.c index 416fb154701..0010553a9d4 100644 --- a/src/gnutls.c +++ b/src/gnutls.c @@ -2298,6 +2298,8 @@ gnutls_symmetric_aead (bool encrypting, gnutls_cipher_algorithm_t gca, # endif } +static Lisp_Object cipher_cache; + static Lisp_Object gnutls_symmetric (bool encrypting, Lisp_Object cipher, Lisp_Object key, Lisp_Object iv, @@ -2329,7 +2331,9 @@ gnutls_symmetric (bool encrypting, Lisp_Object cipher, if (SYMBOLP (cipher)) { - info = Fassq (cipher, Fgnutls_ciphers ()); + if (NILP (cipher_cache)) + cipher_cache = Fgnutls_ciphers (); + info = Fassq (cipher, cipher_cache); if (!CONSP (info)) xsignal2 (Qerror, build_string ("GnuTLS cipher is invalid or not found"), @@ -2914,6 +2918,9 @@ level in the ones. For builds without libgnutls, the value is -1. */); defsubr (&Sgnutls_hash_digest); defsubr (&Sgnutls_symmetric_encrypt); defsubr (&Sgnutls_symmetric_decrypt); + + cipher_cache = Qnil; + staticpro (&cipher_cache); #endif DEFVAR_INT ("gnutls-log-level", global_gnutls_log_level, |
