Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Dashboard: Avoid unnecessary memory allocation #1392

Merged
merged 1 commit into from
Mar 6, 2015
Merged

Dashboard: Avoid unnecessary memory allocation #1392

merged 1 commit into from
Mar 6, 2015

Conversation

mattbostock
Copy link
Contributor

Go's make builtin allocates memory for a new object; a map of
HTTP headers in this case.

According to the documentation for make, memory is allocated for map
types even if the map size is omitted:

Map: An initial allocation is made according to the size but the
resulting map has length 0. The size may be omitted, in which case a
small starting size is allocated.

We can safely omit the Headers field entirely here and avoid
unnecessarily allocating memory.

Go's `make` builtin allocates memory for a new object; a map of
HTTP headers in this case.

According to the [documentation][] for `make`, memory is allocated for map
types even if the map size is omitted:

> Map: An initial allocation is made according to the size but the
> resulting map has length 0. The size may be omitted, in which case a
> small starting size is allocated.

We can safely omit the `Headers` field entirely here and avoid
unnecessarily allocating memory.

[documentation]: http://golang.org/pkg/builtin/#make
rafrombrc added a commit that referenced this pull request Mar 6, 2015
…_memory_allocations

Dashboard: Avoid unnecessary memory allocation
@rafrombrc rafrombrc merged commit b8c6054 into mozilla-services:dev Mar 6, 2015
relistan pushed a commit to Nitro/heka that referenced this pull request Jan 26, 2016
…void_unnecessary_memory_allocations

Dashboard: Avoid unnecessary memory allocation
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants