Skip to content

Operation result being copy/noncopy is inconsistent for some operations #48

Description

@razenpok

I haven't checked other operations, but in some cases add can return the same instance that was passed as left-hand side Decimal.
https://github.com/Patashu/break_infinity.js/blob/master/src/break_infinity.ts#L869

We need to decide if we want Decimal to be

  • Faster, with less allocations
  • Slower, but without pitfalls

I believe that returning the same instance can lead to some quirky bugs caused by innate mutability of Decimal, but it's your call.
Keep in mind that "faster" and "slower" doesn't really mean object allocation itself (which a really lightweight operation), but instead the fact that it will add to garbage and GC will be invoked sooner.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    is this optimal?possible performance improvements

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions