From 6d0057b13ced5a7991ad1b921c4c208895276a2e Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Thu, 2 Apr 2015 17:22:40 +0200 Subject: Improve performance of pygments->mime2lexer Normal arrays are rather slow when accessed sequentially. Use associative arrays and key lookups to reduce the render time of a multipaste with 180 items from 225ms to ~190ms. Signed-off-by: Florian Pritz --- scripts/get_lexer_list.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'scripts/get_lexer_list.py') diff --git a/scripts/get_lexer_list.py b/scripts/get_lexer_list.py index 0ef6fe97a..9453ff733 100755 --- a/scripts/get_lexer_list.py +++ b/scripts/get_lexer_list.py @@ -5,11 +5,14 @@ import json ret = [] +def dictify(list): + return {k:True for k in list} + for fullname, names, exts, mimetypes in pygments.lexers.get_all_lexers(): ret.append({ 'fullname': fullname, - 'names': names, - 'extentions': exts, - 'mimetypes': mimetypes, + 'names': dictify(names), + 'extentions': dictify(exts), + 'mimetypes': dictify(mimetypes), }) print(json.dumps(ret)) -- cgit v1.2.3-24-g4f1b