Skip to content

Conversation

@oldnewthing
Copy link
Member

Previous code constructed a new object each time, even though only the first call will actually need the constructed object. The second and subsequent calls just throw the object away and return the existing object.

Construct the object only if we have a reasonable chance of actually using it. This is a big win for static-lifetime objects that are expensive to construct.

Previous code constructed a new object each time,
even though only the first call will actually need
the constructed object. The second and subsequent
calls just throw the object away and return the
existing object.

Construct the object only if we have a reasonable chance
of actually using it. This is a big win for static-lifetime
objects that are expensive to construct.
@kennykerr
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

No pipelines are associated with this pull request.

Copy link
Collaborator

@kennykerr kennykerr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@kennykerr kennykerr merged commit 469167f into microsoft:master Apr 21, 2020
@oldnewthing oldnewthing deleted the faster-static-lifetime branch May 5, 2020 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants