Skip to content

refactor(core): extract shared write sequence from createSetHandler() #119

@nerdalytics

Description

@nerdalytics

DUP-002

createSetHandler() has a no-onWrite fast path (lines 672–691) that manually inlines the same 6-step sequence performWrite() encapsulates (lines 699–728):

Step Both paths
Read old value rawTarget[prop]
Same-value bail Object.is(oldValue, value)
Capture array length getArrayLengthBeforeMutation
Assign rawTarget[prop] = value
Notify subscribers scheduleSubscribersForTarget
Length change check notifyLengthChangeIfNeeded

The inline version omits checkInfiniteLoop (guarded by !currentEffect) and the hook call, but the structural sequence is duplicated verbatim.

performWrite could handle the hookless case by accepting optional parameters, collapsing two paths into one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions