summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/byte-run.el
diff options
context:
space:
mode:
authorMichal Nazarewicz <mina86@mina86.com>2016-07-17 03:09:38 +0200
committerMichal Nazarewicz <mina86@mina86.com>2016-08-02 15:39:10 +0200
commit4538a5e37e8dacde4b3e828d832c4c558a146912 (patch)
tree43a158bf0635a01bf5946730ac439fd0b3b8f606 /lisp/emacs-lisp/byte-run.el
parente7257061317c604492d20f26f312b9e925aa1860 (diff)
downloademacs-4538a5e37e8dacde4b3e828d832c4c558a146912.tar.gz
Refactor regex character class parsing in [:name:]
re_wctype function is used in three separate places and in all of those places almost exact code extracting the name from [:name:] surrounds it. Furthermore, re_wctype requires a NUL-terminated string, so the name of the character class is copied to a temporary buffer. The code duplication and unnecessary memory copying can be avoided by pushing the responsibility of parsing the whole [:name:] sequence to the function. Furthermore, since now the function has access to the length of the character class name (since it’s doing the parsing), it can take advantage of that information in skipping some string comparisons and using a constant-length memcmp instead of strcmp which needs to take care of NUL bytes. * src/regex.c (re_wctype): Delete function. Replace it with: (re_wctype_parse): New function which parses a whole [:name:] string and returns a RECC_* constant or -1 if the string is not of [:name:] format. (regex_compile): Use re_wctype_parse. * src/syntax.c (skip_chars): Use re_wctype_parse.
Diffstat (limited to 'lisp/emacs-lisp/byte-run.el')
0 files changed, 0 insertions, 0 deletions