Skip to content

performance idea: rewrite to "set iterator with while" or back to Array #2

@betula

Description

@betula
  run = (unsubs) => (
    // can unsubs be modified in run functions?
    unsubs.forEach(fn => fn()), // performance problem here (for of more quick)
    unsubs.clear()
  ),

"for of" perf problem

And return "detach" function no have a reason in most cases:

  attach = (unsubs, fn) => (
    (fn || (fn = unsubs, unsubs = context_unsubs)), <---------- remove "||" performance reason
    unsubs && unsubs.add(fn),
    () => unsubs.delete(fn) // <--------------- remove it performance and size reason
  ),

It should be super small and super fast!

p.s.
May be rewrite back to Array from Set.
May be remove "unsubscriber" function (it's so long name) and type in documentation what it is an array.

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