workerman icon indicating copy to clipboard operation
workerman copied to clipboard

Use static anonymous functions

Open joanhey opened this issue 1 year ago • 1 comments

Will be good to change in all the code and examples.

And explain that's better to use static.

For performance and memory benefit.

Anonymous functions when declared in the context of a class, the current class is automatically bound to it, making $this available inside of the function's scope. If this automatic binding of the current class is not wanted, then static anonymous functions may be used instead.

joanhey avatar Dec 26 '22 17:12 joanhey

I don't object to this proposal, but through stress test comparison, the use of static functions has no significant performance improvement, or even difference.

walkor avatar Dec 27 '22 01:12 walkor