Skip to content

♻️ Make Ok() a singleton - #1176

Merged
cowboyd merged 1 commit into
v4from
singleton-undef
Jun 5, 2026
Merged

♻️ Make Ok() a singleton#1176
cowboyd merged 1 commit into
v4from
singleton-undef

Conversation

@cowboyd

Copy link
Copy Markdown
Member

Motivation

Save allocations along hot paths. Ok() is fundamental construct of flow control and error reporting in effection, it gets allocated a lot, and is used on paths both hot and cold.

Approach

Collapse every Ok() into a single object instance.

@pkg-pr-new

pkg-pr-newBot commented Jun 5, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/effection@1176

commit: 5783766

@codspeed-hq

codspeed-hqBot commented Jun 5, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 6 untouched benchmarks


Comparing singleton-undef (5783766) with v4 (82bd953)

Open in CodSpeed

There is no need to allocate a new Ok<void>() object every single
time since it contains no new information.
@cowboyd
cowboyd merged commit 45fa35e into v4Jun 5, 2026
19 checks passed
@cowboyd
cowboyd deleted the singleton-undef branch June 5, 2026 18:33
@cowboydcowboyd mentioned this pull request Jul 8, 2026
Sign up for freeto 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

@cowboyd@jbolda