diff options
author | Jesús <heckyel@hyperbola.info> | 2019-12-30 16:10:54 -0500 |
---|---|---|
committer | Jesús <heckyel@hyperbola.info> | 2019-12-30 16:10:54 -0500 |
commit | d1d3aaa224ec068dc8d267e4d64255f88b6641a0 (patch) | |
tree | 9e6b679c529dca7217becc7856ea6aac2d3069f7 /lib/PendingRequests.jsm | |
parent | fa6fb12f089ff0170d0f3ee93b6ce7131a6a2254 (diff) | |
download | ematrix-d1d3aaa224ec068dc8d267e4d64255f88b6641a0.tar.lz ematrix-d1d3aaa224ec068dc8d267e4d64255f88b6641a0.tar.xz ematrix-d1d3aaa224ec068dc8d267e4d64255f88b6641a0.zip |
fix syntax libraries
Diffstat (limited to 'lib/PendingRequests.jsm')
-rw-r--r-- | lib/PendingRequests.jsm | 110 |
1 files changed, 55 insertions, 55 deletions
diff --git a/lib/PendingRequests.jsm b/lib/PendingRequests.jsm index 1214c3c..fdfab1e 100644 --- a/lib/PendingRequests.jsm +++ b/lib/PendingRequests.jsm @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see {http://www.gnu.org/licenses/}. - Home: https://gitlab.com/vannilla/ematrix + Home: https://libregit.org/heckyel/ematrix uMatrix Home: https://github.com/gorhill/uMatrix */ @@ -37,61 +37,61 @@ var ringBuffer = new Array(256); var PendingRequestBuffer = (function () { for (let i=ringBuffer.length-1; i>=0; --i) { - ringBuffer[i] = new PendingRequest(); + ringBuffer[i] = new PendingRequest(); } - + return { - createRequest: function (url) { - // URL to ring buffer index map: - // { k = URL, s = ring buffer indices } - // - // s is a string which character codes map to ring buffer - // indices -- for when the same URL is received multiple times - // by shouldLoadListener() before the existing one is serviced - // by the network request observer. I believe the use of a - // string in lieu of an array reduces memory churning. - let bucket; - let i = writePointer; - writePointer = i + 1 & 255; - - let req = ringBuffer[i]; - let str = String.fromCharCode(i); - - if (req._key !== '') { - bucket = urlToIndex.get(req._key); - if (bucket.lenght === 1) { - urlToIndex.delete(req._key); - } else { - let pos = bucket.indexOf(str); - urlToIndex.set(req._key, - bucket.slice(0, pos)+bucket.slice(pos+1)); - } - } - - bucket = urlToIndex.get(url); - urlToIndex.set(url, - (bucket === undefined) ? str : bucket + str); - req._key = url; - - return req; - }, - lookupRequest: function (url) { - let bucket = urlToIndex.get(url); - if (bucket === undefined) { - return null; - } - - let i = bucket.charCodeAt(0); - if (bucket.length === 1) { - urlToIndex.delete(url); - } else { - urlToIndex.set(url, bucket.slice(1)); - } - - let req = ringBuffer[i]; - req._key = ''; - - return req; - }, + createRequest: function (url) { + // URL to ring buffer index map: + // { k = URL, s = ring buffer indices } + // + // s is a string which character codes map to ring buffer + // indices -- for when the same URL is received multiple times + // by shouldLoadListener() before the existing one is serviced + // by the network request observer. I believe the use of a + // string in lieu of an array reduces memory churning. + let bucket; + let i = writePointer; + writePointer = i + 1 & 255; + + let req = ringBuffer[i]; + let str = String.fromCharCode(i); + + if (req._key !== '') { + bucket = urlToIndex.get(req._key); + if (bucket.lenght === 1) { + urlToIndex.delete(req._key); + } else { + let pos = bucket.indexOf(str); + urlToIndex.set(req._key, + bucket.slice(0, pos)+bucket.slice(pos+1)); + } + } + + bucket = urlToIndex.get(url); + urlToIndex.set(url, + (bucket === undefined) ? str : bucket + str); + req._key = url; + + return req; + }, + lookupRequest: function (url) { + let bucket = urlToIndex.get(url); + if (bucket === undefined) { + return null; + } + + let i = bucket.charCodeAt(0); + if (bucket.length === 1) { + urlToIndex.delete(url); + } else { + urlToIndex.set(url, bucket.slice(1)); + } + + let req = ringBuffer[i]; + req._key = ''; + + return req; + }, } })(); |