Skip to content

Increase performance by reducing path parsing #25

@ShaMan123

Description

@ShaMan123

Is your feature request related to a problem? Please describe.

I like this repo.
It seems better in terms of perf, accuracy and flexibility than other alternatives I have worked with (mainly bezier-js).
I use path intersection a lot and in many cases where intersection is tested on paths that do not change a lot.
Therefore, it seems a perf hit to parse these paths every time, especially since perf is a big deal for my use case (area selection or rendering).
I might be wrong but it seems this is the case in the source code. It seems parsing occurs on every call.
Additionally, I would argue that a consumer of this repo will need the path parsed for other usages (path length, getting t or segment by t, calculating bbox) and will probably use other repos for that.
Reducing parsing in runtime sounds ideal.

Describe the solution you'd like

I suggest exposing a signature that receives parsed paths and a signature to parse them.
This doesn't have to be breaking.

Or even better:

export type ParsedPath = ...
export function findPathIntersections(path1: Path | ParsedPath, path2: Path | ParsedPath, justCount?: boolean): Intersection[] | number;

Describe alternatives you've considered

Patching locally or forking

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions