Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allocation optimizations #58

Open
Alloc86 opened this issue Apr 1, 2021 · 0 comments
Open

Allocation optimizations #58

Alloc86 opened this issue Apr 1, 2021 · 0 comments

Comments

@Alloc86
Copy link

Alloc86 commented Apr 1, 2021

As we're using NCalc in a Unity game where allocations are critical I added a few optimizations to reduce them a bit. Not sure if you'd like those to get adopted into mainline, especially the instance caching might not be thread safe.

Changes basically consist of two parts:

  • (Optionally) Reusing instances of FunctionArgs and EvaluationVisitors instead of creating new ones on each evaluation
  • Replacing ToLower calls on strings for case insensitive tests with Equals(, OrdinalIgnoreCase) calls
  • Also as a really minor one I replaced an empty array creation with reusing a single instance of it

0001-Added-instance-caches.txt

Cheers,
Chris

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant