[Issue 7013] Mutable interface for BigInts

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jul 9 10:24:40 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=7013



--- Comment #5 from bearophile_hugs at eml.cc 2013-07-09 10:24:39 PDT ---
(In reply to comment #4)
> You're right, I looked at the code for BigInt, every time you do +=, it
> allocates a new underlying buffer. That's pretty inefficient if you're using
> these operations in an inner loop.

On the other hand I think a mutable integer is not what most people expect, and
it can cause some undesired side effects (and bugs).

That's why I suggested to introduce a specific syntax that allows you to manage
bigints as mutable buffers where max performance is needed, and keep their
behavour clean on default. Generally I think it's better to perform tricky
optimizations only on explicit request.

Some possible alternative syntaxes:

x.mutable += y;
x.mulAcc(y);
x.mutate!"+"(y);

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list