Avoid both for key in object and a lot of indexOf looping

This commit is contained in:
Zixaphir 2014-01-11 00:18:02 -07:00
parent 3a76018fe4
commit 5e73209e35
3 changed files with 107 additions and 82 deletions

View File

@ -9978,16 +9978,25 @@
Redirect = { Redirect = {
init: function() { init: function() {
var archive, archives, boardID, boards, data, files, id, name, o, record, software, type, _i, _len, _ref, _ref1; var archive, archives, boardID, boards, data, files, id, name, o, record, software, type, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _ref3, _ref4;
o = { o = {
thread: {}, thread: {},
post: {}, post: {},
file: {} file: {}
}; };
archives = Redirect.archives; archives = {};
_ref = Conf['selectedArchives']; _ref = Redirect.archives;
for (boardID in _ref) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
record = _ref[boardID]; _ref1 = _ref[_i], name = _ref1.name, boards = _ref1.boards, files = _ref1.files, data = _ref1.data;
archives[name] = {
boards: boards,
files: files,
data: data
};
}
_ref2 = Conf['selectedArchives'];
for (boardID in _ref2) {
record = _ref2[boardID];
for (type in record) { for (type in record) {
id = record[type]; id = record[type];
if (!((archive = archives[id]))) { if (!((archive = archives[id]))) {
@ -10000,11 +10009,12 @@
o[type][boardID] = archive.data; o[type][boardID] = archive.data;
} }
} }
for (name in archives) { _ref3 = Redirect(archives);
_ref1 = archives[name], data = _ref1.data, boards = _ref1.boards, files = _ref1.files; for (_j = 0, _len1 = _ref3.length; _j < _len1; _j++) {
_ref4 = _ref3[_j], data = _ref4.data, boards = _ref4.boards, files = _ref4.files;
software = data.software; software = data.software;
for (_i = 0, _len = boards.length; _i < _len; _i++) { for (_k = 0, _len2 = boards.length; _k < _len2; _k++) {
boardID = boards[_i]; boardID = boards[_k];
if (!(boardID in o.thread)) { if (!(boardID in o.thread)) {
o.thread[boardID] = data; o.thread[boardID] = data;
} }
@ -10018,8 +10028,9 @@
} }
return Redirect.data = o; return Redirect.data = o;
}, },
archives: { archives: [
"Foolz": { {
name: "Foolz",
boards: ["a", "co", "gd", "jp", "m", "sp", "tg", "tv", "v", "vg", "vp", "vr", "wsg"], boards: ["a", "co", "gd", "jp", "m", "sp", "tg", "tv", "v", "vg", "vp", "vr", "wsg"],
files: ["a", "gd", "jp", "m", "tg", "vg", "vp", "vr", "wsg"], files: ["a", "gd", "jp", "m", "tg", "vg", "vp", "vr", "wsg"],
data: { data: {
@ -10028,8 +10039,8 @@
https: true, https: true,
software: "foolfuuka" software: "foolfuuka"
} }
}, }, {
"NSFW Foolz": { name: "NSFW Foolz",
boards: ["u"], boards: ["u"],
files: ["u"], files: ["u"],
data: { data: {
@ -10038,8 +10049,8 @@
https: true, https: true,
software: "foolfuuka" software: "foolfuuka"
} }
}, }, {
"The Dark Cave": { name: "The Dark Cave",
boards: ["c", "int", "out", "po"], boards: ["c", "int", "out", "po"],
files: ["c", "po"], files: ["c", "po"],
data: { data: {
@ -10048,8 +10059,8 @@
https: true, https: true,
software: "foolfuuka" software: "foolfuuka"
} }
}, }, {
"4plebs": { name: "4plebs",
boards: ["hr", "pol", "s4s", "tg", "tv", "x"], boards: ["hr", "pol", "s4s", "tg", "tv", "x"],
files: ["hr", "pol", "s4s", "tg", "tv", "x"], files: ["hr", "pol", "s4s", "tg", "tv", "x"],
data: { data: {
@ -10058,8 +10069,8 @@
https: true, https: true,
software: "foolfuuka" software: "foolfuuka"
} }
}, }, {
"Nyafuu": { name: "Nyafuu",
boards: ["c", "w", "wg"], boards: ["c", "w", "wg"],
files: ["c", "w", "wg"], files: ["c", "w", "wg"],
data: { data: {
@ -10068,8 +10079,8 @@
https: true, https: true,
software: "foolfuuka" software: "foolfuuka"
} }
}, }, {
"Install Gentoo": { name: "Install Gentoo",
boards: ["diy", "g", "sci"], boards: ["diy", "g", "sci"],
files: [], files: [],
data: { data: {
@ -10078,8 +10089,8 @@
https: true, https: true,
software: "fuuka" software: "fuuka"
} }
}, }, {
"Rebecca Black Tech": { name: "Rebecca Black Tech",
boards: ["cgl", "g", "mu", "w"], boards: ["cgl", "g", "mu", "w"],
files: ["cgl", "g", "mu", "w"], files: ["cgl", "g", "mu", "w"],
data: { data: {
@ -10088,8 +10099,8 @@
https: true, https: true,
software: "fuuka" software: "fuuka"
} }
}, }, {
"Heinessen": { name: "Heinessen",
boards: ["an", "fit", "k", "mlp", "r9k", "toy"], boards: ["an", "fit", "k", "mlp", "r9k", "toy"],
files: ["an", "fit", "k", "r9k", "toy"], files: ["an", "fit", "k", "r9k", "toy"],
data: { data: {
@ -10097,8 +10108,8 @@
http: true, http: true,
software: "fuuka" software: "fuuka"
} }
}, }, {
"warosu": { name: "warosu",
boards: ["3", "cgl", "ck", "fa", "ic", "jp", "lit", "tg", "vr"], boards: ["3", "cgl", "ck", "fa", "ic", "jp", "lit", "tg", "vr"],
files: ["3", "cgl", "ck", "fa", "ic", "jp", "lit", "tg", "vr"], files: ["3", "cgl", "ck", "fa", "ic", "jp", "lit", "tg", "vr"],
data: { data: {
@ -10107,8 +10118,8 @@
https: true, https: true,
software: "fuuka" software: "fuuka"
} }
}, }, {
"Foolz Beta": { name: "Foolz Beta",
boards: ["a", "co", "d", "gd", "h", "jp", "m", "mlp", "sp", "tg", "tv", "u", "v", "vg", "vp", "vr", "wsg"], boards: ["a", "co", "d", "gd", "h", "jp", "m", "mlp", "sp", "tg", "tv", "u", "v", "vg", "vp", "vr", "wsg"],
files: ["a", "d", "gd", "h", "jp", "m", "tg", "u", "vg", "vp", "vr", "wsg"], files: ["a", "d", "gd", "h", "jp", "m", "tg", "u", "vg", "vp", "vr", "wsg"],
data: { data: {
@ -10119,7 +10130,7 @@
software: "foolfuuka" software: "foolfuuka"
} }
} }
}, ],
to: function(dest, data) { to: function(dest, data) {
var archive; var archive;
archive = (dest === 'search' ? Redirect.data.thread : Redirect.data[dest])[data.boardID]; archive = (dest === 'search' ? Redirect.data.thread : Redirect.data[dest])[data.boardID];

View File

@ -9967,16 +9967,25 @@
Redirect = { Redirect = {
init: function() { init: function() {
var archive, archives, boardID, boards, data, files, id, name, o, record, software, type, _i, _len, _ref, _ref1; var archive, archives, boardID, boards, data, files, id, name, o, record, software, type, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _ref3, _ref4;
o = { o = {
thread: {}, thread: {},
post: {}, post: {},
file: {} file: {}
}; };
archives = Redirect.archives; archives = {};
_ref = Conf['selectedArchives']; _ref = Redirect.archives;
for (boardID in _ref) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
record = _ref[boardID]; _ref1 = _ref[_i], name = _ref1.name, boards = _ref1.boards, files = _ref1.files, data = _ref1.data;
archives[name] = {
boards: boards,
files: files,
data: data
};
}
_ref2 = Conf['selectedArchives'];
for (boardID in _ref2) {
record = _ref2[boardID];
for (type in record) { for (type in record) {
id = record[type]; id = record[type];
if (!((archive = archives[id]))) { if (!((archive = archives[id]))) {
@ -9989,11 +9998,12 @@
o[type][boardID] = archive.data; o[type][boardID] = archive.data;
} }
} }
for (name in archives) { _ref3 = Redirect(archives);
_ref1 = archives[name], data = _ref1.data, boards = _ref1.boards, files = _ref1.files; for (_j = 0, _len1 = _ref3.length; _j < _len1; _j++) {
_ref4 = _ref3[_j], data = _ref4.data, boards = _ref4.boards, files = _ref4.files;
software = data.software; software = data.software;
for (_i = 0, _len = boards.length; _i < _len; _i++) { for (_k = 0, _len2 = boards.length; _k < _len2; _k++) {
boardID = boards[_i]; boardID = boards[_k];
if (!(boardID in o.thread)) { if (!(boardID in o.thread)) {
o.thread[boardID] = data; o.thread[boardID] = data;
} }
@ -10007,8 +10017,9 @@
} }
return Redirect.data = o; return Redirect.data = o;
}, },
archives: { archives: [
"Foolz": { {
name: "Foolz",
boards: ["a", "co", "gd", "jp", "m", "sp", "tg", "tv", "v", "vg", "vp", "vr", "wsg"], boards: ["a", "co", "gd", "jp", "m", "sp", "tg", "tv", "v", "vg", "vp", "vr", "wsg"],
files: ["a", "gd", "jp", "m", "tg", "vg", "vp", "vr", "wsg"], files: ["a", "gd", "jp", "m", "tg", "vg", "vp", "vr", "wsg"],
data: { data: {
@ -10017,8 +10028,8 @@
https: true, https: true,
software: "foolfuuka" software: "foolfuuka"
} }
}, }, {
"NSFW Foolz": { name: "NSFW Foolz",
boards: ["u"], boards: ["u"],
files: ["u"], files: ["u"],
data: { data: {
@ -10027,8 +10038,8 @@
https: true, https: true,
software: "foolfuuka" software: "foolfuuka"
} }
}, }, {
"The Dark Cave": { name: "The Dark Cave",
boards: ["c", "int", "out", "po"], boards: ["c", "int", "out", "po"],
files: ["c", "po"], files: ["c", "po"],
data: { data: {
@ -10037,8 +10048,8 @@
https: true, https: true,
software: "foolfuuka" software: "foolfuuka"
} }
}, }, {
"4plebs": { name: "4plebs",
boards: ["hr", "pol", "s4s", "tg", "tv", "x"], boards: ["hr", "pol", "s4s", "tg", "tv", "x"],
files: ["hr", "pol", "s4s", "tg", "tv", "x"], files: ["hr", "pol", "s4s", "tg", "tv", "x"],
data: { data: {
@ -10047,8 +10058,8 @@
https: true, https: true,
software: "foolfuuka" software: "foolfuuka"
} }
}, }, {
"Nyafuu": { name: "Nyafuu",
boards: ["c", "w", "wg"], boards: ["c", "w", "wg"],
files: ["c", "w", "wg"], files: ["c", "w", "wg"],
data: { data: {
@ -10057,8 +10068,8 @@
https: true, https: true,
software: "foolfuuka" software: "foolfuuka"
} }
}, }, {
"Install Gentoo": { name: "Install Gentoo",
boards: ["diy", "g", "sci"], boards: ["diy", "g", "sci"],
files: [], files: [],
data: { data: {
@ -10067,8 +10078,8 @@
https: true, https: true,
software: "fuuka" software: "fuuka"
} }
}, }, {
"Rebecca Black Tech": { name: "Rebecca Black Tech",
boards: ["cgl", "g", "mu", "w"], boards: ["cgl", "g", "mu", "w"],
files: ["cgl", "g", "mu", "w"], files: ["cgl", "g", "mu", "w"],
data: { data: {
@ -10077,8 +10088,8 @@
https: true, https: true,
software: "fuuka" software: "fuuka"
} }
}, }, {
"Heinessen": { name: "Heinessen",
boards: ["an", "fit", "k", "mlp", "r9k", "toy"], boards: ["an", "fit", "k", "mlp", "r9k", "toy"],
files: ["an", "fit", "k", "r9k", "toy"], files: ["an", "fit", "k", "r9k", "toy"],
data: { data: {
@ -10086,8 +10097,8 @@
http: true, http: true,
software: "fuuka" software: "fuuka"
} }
}, }, {
"warosu": { name: "warosu",
boards: ["3", "cgl", "ck", "fa", "ic", "jp", "lit", "tg", "vr"], boards: ["3", "cgl", "ck", "fa", "ic", "jp", "lit", "tg", "vr"],
files: ["3", "cgl", "ck", "fa", "ic", "jp", "lit", "tg", "vr"], files: ["3", "cgl", "ck", "fa", "ic", "jp", "lit", "tg", "vr"],
data: { data: {
@ -10096,8 +10107,8 @@
https: true, https: true,
software: "fuuka" software: "fuuka"
} }
}, }, {
"Foolz Beta": { name: "Foolz Beta",
boards: ["a", "co", "d", "gd", "h", "jp", "m", "mlp", "sp", "tg", "tv", "u", "v", "vg", "vp", "vr", "wsg"], boards: ["a", "co", "d", "gd", "h", "jp", "m", "mlp", "sp", "tg", "tv", "u", "v", "vg", "vp", "vr", "wsg"],
files: ["a", "d", "gd", "h", "jp", "m", "tg", "u", "vg", "vp", "vr", "wsg"], files: ["a", "d", "gd", "h", "jp", "m", "tg", "u", "vg", "vp", "vr", "wsg"],
data: { data: {
@ -10108,7 +10119,7 @@
software: "foolfuuka" software: "foolfuuka"
} }
} }
}, ],
to: function(dest, data) { to: function(dest, data) {
var archive; var archive;
archive = (dest === 'search' ? Redirect.data.thread : Redirect.data[dest])[data.boardID]; archive = (dest === 'search' ? Redirect.data.thread : Redirect.data[dest])[data.boardID];

View File

@ -6,7 +6,9 @@ Redirect =
post: {} post: {}
file: {} file: {}
{archives} = Redirect archives = {}
for {name, boards, files, data} in Redirect.archives
archives[name] = {boards, files, data}
for boardID, record of Conf['selectedArchives'] for boardID, record of Conf['selectedArchives']
for type, id of record when (archive = archives[id]) for type, id of record when (archive = archives[id])
@ -14,7 +16,7 @@ Redirect =
continue unless boardID in boards continue unless boardID in boards
o[type][boardID] = archive.data o[type][boardID] = archive.data
for name, {data, boards, files} of archives for {data, boards, files} in Redirect archives
{software} = data {software} = data
for boardID in boards for boardID in boards
o.thread[boardID] = data unless boardID of o.thread o.thread[boardID] = data unless boardID of o.thread
@ -23,8 +25,8 @@ Redirect =
Redirect.data = o Redirect.data = o
archives: archives: [
"Foolz": name: "Foolz"
boards: ["a", "co", "gd", "jp", "m", "sp", "tg", "tv", "v", "vg", "vp", "vr", "wsg"] boards: ["a", "co", "gd", "jp", "m", "sp", "tg", "tv", "v", "vg", "vp", "vr", "wsg"]
files: ["a", "gd", "jp", "m", "tg", "vg", "vp", "vr", "wsg"] files: ["a", "gd", "jp", "m", "tg", "vg", "vp", "vr", "wsg"]
data: data:
@ -32,8 +34,8 @@ Redirect =
http: false http: false
https: true https: true
software: "foolfuuka" software: "foolfuuka"
,
"NSFW Foolz": name: "NSFW Foolz"
boards: ["u"] boards: ["u"]
files: ["u"] files: ["u"]
data: data:
@ -41,8 +43,8 @@ Redirect =
http: false http: false
https: true https: true
software: "foolfuuka" software: "foolfuuka"
,
"The Dark Cave": name: "The Dark Cave"
boards: ["c", "int", "out", "po"] boards: ["c", "int", "out", "po"]
files: ["c", "po"] files: ["c", "po"]
data: data:
@ -50,8 +52,8 @@ Redirect =
http: true http: true
https: true https: true
software: "foolfuuka" software: "foolfuuka"
,
"4plebs": name: "4plebs"
boards: ["hr", "pol", "s4s", "tg", "tv", "x"] boards: ["hr", "pol", "s4s", "tg", "tv", "x"]
files: ["hr", "pol", "s4s", "tg", "tv", "x"] files: ["hr", "pol", "s4s", "tg", "tv", "x"]
data: data:
@ -59,8 +61,8 @@ Redirect =
http: true http: true
https: true https: true
software: "foolfuuka" software: "foolfuuka"
,
"Nyafuu": name: "Nyafuu"
boards: ["c", "w", "wg"] boards: ["c", "w", "wg"]
files: ["c", "w", "wg"] files: ["c", "w", "wg"]
data: data:
@ -68,8 +70,8 @@ Redirect =
http: true http: true
https: true https: true
software: "foolfuuka" software: "foolfuuka"
,
"Install Gentoo": name: "Install Gentoo"
boards: ["diy", "g", "sci"] boards: ["diy", "g", "sci"]
files: [] files: []
data: data:
@ -77,8 +79,8 @@ Redirect =
http: false http: false
https: true https: true
software: "fuuka" software: "fuuka"
,
"Rebecca Black Tech": name: "Rebecca Black Tech"
boards: ["cgl", "g", "mu", "w"] boards: ["cgl", "g", "mu", "w"]
files: ["cgl", "g", "mu", "w"] files: ["cgl", "g", "mu", "w"]
data: data:
@ -86,16 +88,16 @@ Redirect =
http: true http: true
https: true https: true
software: "fuuka" software: "fuuka"
,
"Heinessen": name: "Heinessen"
boards: ["an", "fit", "k", "mlp", "r9k", "toy"] boards: ["an", "fit", "k", "mlp", "r9k", "toy"]
files: ["an", "fit", "k", "r9k", "toy"] files: ["an", "fit", "k", "r9k", "toy"]
data: data:
domain: "archive.heinessen.com" domain: "archive.heinessen.com"
http: true http: true
software: "fuuka" software: "fuuka"
,
"warosu": name: "warosu"
boards: ["3", "cgl", "ck", "fa", "ic", "jp", "lit", "tg", "vr"] boards: ["3", "cgl", "ck", "fa", "ic", "jp", "lit", "tg", "vr"]
files: ["3", "cgl", "ck", "fa", "ic", "jp", "lit", "tg", "vr"] files: ["3", "cgl", "ck", "fa", "ic", "jp", "lit", "tg", "vr"]
data: data:
@ -103,8 +105,8 @@ Redirect =
http: true http: true
https: true https: true
software: "fuuka" software: "fuuka"
,
"Foolz Beta": name: "Foolz Beta"
boards: ["a", "co", "d", "gd", "h", "jp", "m", "mlp", "sp", "tg", "tv", "u", "v", "vg", "vp", "vr", "wsg"], boards: ["a", "co", "d", "gd", "h", "jp", "m", "mlp", "sp", "tg", "tv", "u", "v", "vg", "vp", "vr", "wsg"],
files: ["a", "d", "gd", "h", "jp", "m", "tg", "u", "vg", "vp", "vr", "wsg"] files: ["a", "d", "gd", "h", "jp", "m", "tg", "u", "vg", "vp", "vr", "wsg"]
data: data:
@ -113,6 +115,7 @@ Redirect =
https: true https: true
withCredentials: true withCredentials: true
software: "foolfuuka" software: "foolfuuka"
]
to: (dest, data) -> to: (dest, data) ->
archive = (if dest is 'search' then Redirect.data.thread else Redirect.data[dest])[data.boardID] archive = (if dest is 'search' then Redirect.data.thread else Redirect.data[dest])[data.boardID]