Repository navigation
Removed decimal math from the numeric handler - #1959
Conversation
roji
left a comment
There was a problem hiding this comment.
No time for a deep review, although the approach is very nice, with the unsafe casting of decimal to and from DecimalRaw.
Just to extra paranoid, I'm assuming that the internal memory structure of .NET numeric guaranteed by the runtime specs, so that we know for sure it will never change?
Aside from that LGTM, modulu the two minor comments below.
There was a problem hiding this comment.
Any reason not to make this a regular, non-static method (i.e. Add(uint addend) which modifies this)? Same for the methods below.
There was a problem hiding this comment.
You are right here because the struct is used only for local variables, but as you know if it is used as parameter, then an instance method is called on a copy. Therefore, I prefer to follow the guidelines and do not implement instance methods in a mutable struct.
There was a problem hiding this comment.
Yeah, I know about "mutable structs are evil", but I think sometimes it goes a little too far - as long as everyone is aware it's not that bad. Also as long as the struct itself is passed by ref (as should be the case for big structs) it should be fine. But anyway as you wish.
There was a problem hiding this comment.
It's not a ref struct anymore.
There was a problem hiding this comment.
I didn't mean that it's a ref struct, only that it gets passed around by reference (via ref parameters). With a large struct, passing by ref reduces the copying and also makes it less error-prone for the class to be mutable...
There was a problem hiding this comment.
Probably a good idea to assert that Read() returned true
There was a problem hiding this comment.
A good idea, will do.
|
@YohDeadfall, @StillLearnin and anyone else, for extra credit we also have #448, which would allow reading/writing PostgreSQL |
Okay, I'm going to merge the PR. You can review it later, and I will push requested changes as a separate pull request. By the way, yesterday I realized how to make the new implementation a bit faster, but will do it for 4.0.1.
Yes, we can be sure that it will never change. It's a breaking change for .NET. |
|
Looks good to me! Thanks for checking. |
Environment
Before
After
/cc @StillLearnin @Brar