tattali / CalendarBundle

Provides event calendar for your Symfony project. Compatible with API like Google Calendar.
https://packagist.org/packages/tattali/calendar-bundle
MIT License
147 stars 22 forks source link

Performance issue in CalendatEvent class #46

Closed fdiedler closed 8 months ago

fdiedler commented 2 years ago

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 _inarray() 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,

Chris53897 commented 1 year ago

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