Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
avatar: Remove URL computation in FallbackAvatarURL's pseudo-construc…
…tor. Specifically, in its static `validateAndConstructInstance` method. In working on the recently merged zulip#4230, we found that calling `new URL` with ordinary input is quite expensive, and so we arranged to not call it when rehydrating. We left the call in `validateAndConstructInstance`, though, thinking we couldn't possibly remove it and still validate the raw server data properly at the edge. When we did some performance benchmarking after zulip#4230 was merged [1], though, we found that `api.registerForEvents` started to take a lot longer after zulip#4230 than before it. Profiling [2] suggested that we could help speed things up if we could just stop calling `new URL` in `validateAndConstructInstance`. Looking closer, thankfully, it's possible and reasonably easy. We would normally avoid string concatenation for URLs entirely, but this is a case where we can do it in a fairly principled way (see the implementation comment in the diff). [1] https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/user_avatar_url_field_optional/near/1080919 [2] https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/user_avatar_url_field_optional/near/1081240 [3] https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/user_avatar_url_field_optional/near/1081253
- Loading branch information