tattali / CalendarBundle

Provides event calendar for your Symfony project. Compatible with API like Google Calendar.

Home Page:https://packagist.org/packages/tattali/calendar-bundle

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Performance issue in CalendatEvent class

fdiedler opened this issue · 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,

commented

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