Changing for...in loop for performance.
This commit is contained in:
parent
88414d61f7
commit
460de6e436
1 changed files with 8 additions and 11 deletions
|
|
@ -44,9 +44,8 @@ export default {
|
||||||
parseQueryParms() {
|
parseQueryParms() {
|
||||||
// Dump the query string parameters into an array. Remove casing on the key for easy compare.
|
// Dump the query string parameters into an array. Remove casing on the key for easy compare.
|
||||||
const queryStringParams = [];
|
const queryStringParams = [];
|
||||||
const params = Object.keys(this.$route.query);
|
|
||||||
|
|
||||||
params.forEach((param) => {
|
Object.keys(this.$route.query).forEach((param) => {
|
||||||
queryStringParams[param.toLowerCase()] = this.$route.query[param];
|
queryStringParams[param.toLowerCase()] = this.$route.query[param];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -127,19 +126,17 @@ export default {
|
||||||
try {
|
try {
|
||||||
const clientParams = JSON.parse(configParams);
|
const clientParams = JSON.parse(configParams);
|
||||||
|
|
||||||
// TODO: Modify to not iterate entire prototype chain
|
Object.keys(clientParams).forEach((cparam) => {
|
||||||
for (const cparam in clientParams) {
|
|
||||||
const cname = clientParams[cparam].toLowerCase();
|
const cname = clientParams[cparam].toLowerCase();
|
||||||
|
|
||||||
// TODO: Modify to not iterate entire prototype chain
|
Object.keys(queryStringParams).forEach((qsparam) => {
|
||||||
for (const qsparam in queryStringParams) {
|
|
||||||
const qsname = qsparam.toLowerCase();
|
const qsname = qsparam.toLowerCase();
|
||||||
|
|
||||||
if (cname === qsname) {
|
if (cname === qsname) {
|
||||||
finalParams[cname] = queryStringParams[cname];
|
finalParams[cname] = queryStringParams[cname];
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
window.console.error(`Error combining client parameters: ${e}`);
|
window.console.error(`Error combining client parameters: ${e}`);
|
||||||
}
|
}
|
||||||
|
|
@ -148,8 +145,8 @@ export default {
|
||||||
},
|
},
|
||||||
populateStoreItemsFromParams(params) {
|
populateStoreItemsFromParams(params) {
|
||||||
// Populate store items from parameters.
|
// Populate store items from parameters.
|
||||||
// TODO: Modify to not iterate entire prototype chain
|
|
||||||
for (const param in params) {
|
Object.keys(params).forEach((param) => {
|
||||||
const name = param.toLowerCase();
|
const name = param.toLowerCase();
|
||||||
const value = params[param];
|
const value = params[param];
|
||||||
|
|
||||||
|
|
@ -184,7 +181,7 @@ export default {
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue