From 1ab1aa1e3857754e08ef922ab6b4567a04712e2f Mon Sep 17 00:00:00 2001 From: Tim Date: Fri, 1 Mar 2019 21:39:35 +0100 Subject: [PATCH] added caching to parse() function --- index.html | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/index.html b/index.html index 5efae9c..b2d620c 100644 --- a/index.html +++ b/index.html @@ -1044,9 +1044,16 @@ this._protocolRegex = /^[a-zA-Z]+:\/\//i; this._urlRegex = /^((https?:\/\/)?[\w-]+(\.[\w-]+)+\.?(:\d+)?(\/\S*)?)$/i; this.parse = this.parse.bind(this); + this._lastQuery = ""; + this._lastParse; } parse(query) { + if (this._lastQuery === query) { + return this._lastParse; + } + this._lastQuery = query; + const res = { query: query, split: null }; if (this._urlRegex.test(query)) { @@ -1090,6 +1097,7 @@ } res.color = QueryParser._getColorFromUrl(this._commands, res.redirect); + this._lastParse = res; return res; }