Skip to content

Optimization opportunity to reuse service struct allocations in github.Client #389

@mdempsky

Description

@mdempsky

All of github.Client's service fields point to objects with identical underlying struct types. Currently they're each separately heap allocated, but they could be made to reuse the same memory. For example, add a field to github.Client:

       self       struct{ client *Client }

And then change github.NewClient to initialize the service fields as so:

       c.self.client = c
       c.Activity = (*ActivityService)(&c.self)
       c.Authorizations = (*AuthorizationsService)(&c.self)
       c.Gists = (*GistsService)(&c.self)
       ...

Just a random observation while looking at the API/implementation. Feel free to close if you don't think this optimization is worthwhile.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions