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

View File

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

View File

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