Closed Bug 1585224 Opened 5 months ago Closed 5 months ago

Cache calUtils get*Service calls to reduce XPCOM overhead

Categories

(Calendar :: General, enhancement)

enhancement
Not set

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: darktrojan, Assigned: darktrojan)

Details

(Keywords: perf)

Attachments

(1 file)

Every time we ask calUtils for a service, it goes to XPCOM and asks to getService(). This is expensive, and we do it a lot. Since services are singletons that don't change, we should only do it once and remember the result.

Attachment #9097555 - Flags: review?(philipp)

This is expensive, and we do it a lot.

In what places/actions do you expect users to notice/see improvement - startup for example?

Summary: Cache calUtils get*Service calls → Cache calUtils get*Service calls to reduce XPCOM overhead
Comment on attachment 9097555 [details] [diff] [review]
1585224-cache-getservice-1.diff

Review of attachment 9097555 [details] [diff] [review]:
-----------------------------------------------------------------

::: calendar/base/modules/calUtils.jsm
@@ +20,5 @@
>  
> +// Cache services to avoid calling getService over and over again. The cache is
> +// a separate object to avoid polluting `cal`, and is defined here since a call
> +// to `_service` will require it to already exist.
> +var ServiceCache = {};

gServiceCache
Attachment #9097555 - Flags: review?(philipp) → review+

Pushed by geoff@darktrojan.net:
https://hg.mozilla.org/comm-central/rev/b3b5a9cd7a32
Cache calUtils getService calls; r=Fallen

Status: ASSIGNED → RESOLVED
Closed: 5 months ago
Resolution: --- → FIXED
Target Milestone: --- → 71
You need to log in before you can comment on or make changes to this bug.