-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add CalcResult<T> class #61
base: main
Are you sure you want to change the base?
Conversation
Vovanda
commented
Jul 28, 2020
- Provides the ability to use standard arithmetic operators
- Replaces the usual approach to throw an exception or return the null in case of an execution failure
Provides the ability to use standard arithmetic operators Replaces the usual approach to throw an exception or return the null in case of an execution failure
Add simple integration test Add tests on arithmetic operations and use operators
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Круто!!!!! Красавчик!!!! Так держать!!!!!! Любим тебя!!!!!!!!! 🥇 🥇 🥇
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Vovanda what do you think about these issues?
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
public CalcResult<T> Add(T a) | ||
{ | ||
if (IsValid) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each if
statement will add additional performance overhead. And conditional jump instruction is much slower than addition instruction.
{ | ||
_value = Arithmetic<T>.Add(_value, a); | ||
} | ||
catch (Exception e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason to add exceptions tracking here?
} | ||
} | ||
|
||
public bool IsValid { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you want to store the validity state of the result?
I suggest you to look into the |