CalendarBundle icon indicating copy to clipboard operation
CalendarBundle copied to clipboard

Performance issue in CalendatEvent class

Open fdiedler opened this issue 2 years ago • 1 comments

Hi,

After profiling my code, I found a performance issue in this function :

    public function addEvent(Event $event): self
    {
        if (!\in_array($event, $this->events, true)) {
            $this->events[] = $event;
        }
        return $this;
    }

Indeed, the performance of in_array() php function is horrible. Can you provide another function using isset() or even with no verification of duplicates ?

You can see in the Symfony Profiler, 1500ms to load 27 000 events without the check in addEvent() function VS 3100ms...

without_check with_inarray , Thanks,

fdiedler avatar Jan 04 '22 14:01 fdiedler

@fdiedler Can you please check the new Version 1.2.4? I guess this Issue can be closed.

Chris53897 avatar Jul 05 '23 06:07 Chris53897