summaryrefslogtreecommitdiff
path: root/searx/webapp.py
diff options
context:
space:
mode:
authorDalf <alex@al-f.net>2019-11-15 09:31:37 +0100
committerDalf <alex@al-f.net>2019-11-15 09:33:15 +0100
commit85b37233458c21b775bf98568c0a5c9260aa14fe (patch)
tree4b79330d170d3f8dbc0c52dadbfef429c31b2187 /searx/webapp.py
parent42d5e2c02cd4715a0e09411efbb249ef5d8defed (diff)
downloadsearxng-85b37233458c21b775bf98568c0a5c9260aa14fe.tar.gz
searxng-85b37233458c21b775bf98568c0a5c9260aa14fe.zip
[mod] speed optimization
compile XPath only once avoid redundant call to urlparse get_locale(webapp.py): avoid useless call to request.accept_languages.best_match
Diffstat (limited to 'searx/webapp.py')
-rw-r--r--searx/webapp.py16
1 files changed, 7 insertions, 9 deletions
diff --git a/searx/webapp.py b/searx/webapp.py
index 3bb29140a..00895d96c 100644
--- a/searx/webapp.py
+++ b/searx/webapp.py
@@ -154,20 +154,18 @@ outgoing_proxies = settings['outgoing'].get('proxies') or None
@babel.localeselector
def get_locale():
- locale = request.accept_languages.best_match(settings['locales'].keys())
-
- if request.preferences.get_value('locale') != '':
- locale = request.preferences.get_value('locale')
+ if 'locale' in request.form\
+ and request.form['locale'] in settings['locales']:
+ return request.form['locale']
if 'locale' in request.args\
and request.args['locale'] in settings['locales']:
- locale = request.args['locale']
+ return request.args['locale']
- if 'locale' in request.form\
- and request.form['locale'] in settings['locales']:
- locale = request.form['locale']
+ if request.preferences.get_value('locale') != '':
+ return request.preferences.get_value('locale')
- return locale
+ return request.accept_languages.best_match(settings['locales'].keys())
# code-highlighter