mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
Replaced lodash.{pick,union}
with native JS
- this code is a hotpath for the URL service and has shown to be slow for sites with a lot of posts - this is because of the overhead of lodash - we can just do away with lodash and use native JS, which has a negligible performance cost - this cuts about 5% CPU time during boot of large sites
This commit is contained in:
parent
30220aa6ef
commit
dd68fca968
1 changed files with 4 additions and 5 deletions
|
@ -164,11 +164,10 @@ module.exports = function (Bookshelf) {
|
||||||
|
|
||||||
let options = _.cloneDeep(unfilteredOptions);
|
let options = _.cloneDeep(unfilteredOptions);
|
||||||
const extraAllowedProperties = filterConfig.extraAllowedProperties || [];
|
const extraAllowedProperties = filterConfig.extraAllowedProperties || [];
|
||||||
let permittedOptions;
|
const permittedOptions = [...new Set([...this.permittedOptions(methodName, options), ...extraAllowedProperties])];
|
||||||
|
options = Object.fromEntries(
|
||||||
permittedOptions = this.permittedOptions(methodName, options);
|
Object.entries(options).filter(([key]) => permittedOptions.includes(key))
|
||||||
permittedOptions = _.union(permittedOptions, extraAllowedProperties);
|
);
|
||||||
options = _.pick(options, permittedOptions);
|
|
||||||
|
|
||||||
if (this.defaultRelations) {
|
if (this.defaultRelations) {
|
||||||
options = this.defaultRelations(methodName, options);
|
options = this.defaultRelations(methodName, options);
|
||||||
|
|
Loading…
Add table
Reference in a new issue