sharp icon indicating copy to clipboard operation
sharp copied to clipboard

getDataKeys() many times

Open pulwar1 opened this issue 2 years ago • 2 comments

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) {

pulwar1 avatar Feb 15 '23 10:02 pulwar1

I can't see the issue here, could you be more specific?

dvlpp avatar Aug 22 '23 12:08 dvlpp

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);
        })           

pulwar1 avatar Sep 14 '23 10:09 pulwar1