eloquent / enumeration

An enumeration implementation for PHP.
MIT License
147 stars 8 forks source link

replace array_key_exists calls with isset($array[$needle]) #21

Closed berturion closed 5 years ago

berturion commented 8 years ago

Just a little enhancement you could implement to have better performances: as array_key_exists is slower than testing an array entry with isset, maybe you could replace some parts of code that uses array_key_exits with isset ? Not a big deal though. Very good module :)

ezzatron commented 8 years ago

That should be more performant, yes. I'm sure there are a bunch of places where better choices could be made performance-wise.

I haven't been too concerned about performance with enumeration. It's probably not a good choice to use it code where performance is critical, simply because using it involves a lot of method calls, which are slow in PHP < 7.

If you're having specific performance issues though, please let me know your use case and I'll see what I can do.

berturion commented 8 years ago

It was just a thought of a little enhancement, there is no problem for my use cases :) Maybe if I have time I will send a pull request. I don't mind if you want to close the issue to clean your repo (or keep it to do it later).

Bilge commented 8 years ago

array_key_exists is not functionally equivalent to isset(). The performance gains you claim are not cited and probably micro anyway.