final-form / final-form

🏁 Framework agnostic, high performance, subscription-based form state management

Home Page:https://final-form.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`toPath` is very expensive

asazernik opened this issue · comments

Almost all of the execution time of registerField() is spent in toPath(), specifically on the string-splitting.

As this is modeled after lodash, I looked at their implementation. Being lodash, they hand-rolled a tokenizer, but even so they felt it necessary to memoize the thing, indicating that this is just an inherently expensive operation.

Since no-deps is a goal, I see three options:

  1. Hand-roll our own memoization support
  2. Include a copy of lodash's memoize in our build (see if the build system will handle this for us)
  3. Include a copy of lodash's stringToPath in our build (again, see if the build system will deal with this)

Are you submitting a bug report or a feature request?

What is the current behavior?

What is the expected behavior?

Sandbox Link

What's your environment?

Other information

I was profiling my app today (which uses deeply nested paths) and came to same conclusion regarding the toPath-function performance (and the need for memoization). It there any update to this issue or plans for a fix in near future?