sharp
sharp copied to clipboard
getDataKeys() many times
Could i ask you to put getDataKeys() in Code16\Sharp\Utils\Fields\HandleFormFields before running filter (not every time)? $formattedData = collect($data) ->filter(function ($value, $key) { // Filter only configured fields return in_array($key, $this->getDataKeys()); })
As you did it in
Code16\Sharp\EntityList\SharpEntityList
$keys = $this->getDataKeys(); $items = collect($items) ->map(function ($row) use ($keys) {
I can't see the issue here, could you be more specific?
If it is not a problem why do you use the different ways? Just compare https://github.com/code16/sharp/blob/main/src/Utils/Fields/HandleFormFields.php#L21 vs https://github.com/code16/sharp/blob/main/src/EntityList/SharpEntityList.php#L92
And please compare count of running $this->getDataKeys()
in variant
$formattedData = collect($data)
->filter(function ($value, $key) {
// Filter only configured fields
return in_array($key, $this->getDataKeys());
});
and variant
$cacheKeys = $this->getDataKeys();
$formattedData = collect($data)
->filter(function ($value, $key) use ($cacheKeys) {
// Filter only configured fields
return in_array($key, $cacheKeys);
})