Improved performance for binary calculations

This commit is contained in:
Deukhoofd 2019-05-25 12:51:39 +02:00
parent f1fbf7044b
commit ce3be6a039
No known key found for this signature in database
GPG Key ID: B4C087AC81641654
1 changed files with 48 additions and 32 deletions

View File

@ -2,49 +2,65 @@
#include "NumericEvalValue.hpp"
NumericEvalValue *NumericEvalValue::operator+(NumericEvalValue *b) {
if (this->IsFloat() && b->IsFloat()){
if (this->IsFloat()){
if (b->IsFloat()){
return new FloatEvalValue(this->GetFloatValue() + b->GetFloatValue());
} else if (this->IsFloat()){
} else{
return new FloatEvalValue(this->GetFloatValue() + b->GetIntegerValue());
} else if (b->IsFloat()){
}
} else {
if (b->IsFloat()){
return new FloatEvalValue(this->GetIntegerValue() + b->GetFloatValue());
} else{
return new IntegerEvalValue(this->GetIntegerValue() + b->GetIntegerValue());
}
}
}
NumericEvalValue *NumericEvalValue::operator-(NumericEvalValue *b) {
if (this->IsFloat() && b->IsFloat()){
if (this->IsFloat()){
if (b->IsFloat()){
return new FloatEvalValue(this->GetFloatValue() - b->GetFloatValue());
} else if (this->IsFloat()){
} else{
return new FloatEvalValue(this->GetFloatValue() - b->GetIntegerValue());
} else if (b->IsFloat()){
}
} else {
if (b->IsFloat()){
return new FloatEvalValue(this->GetIntegerValue() - b->GetFloatValue());
} else{
return new IntegerEvalValue(this->GetIntegerValue() - b->GetIntegerValue());
}
}
}
NumericEvalValue *NumericEvalValue::operator*(NumericEvalValue *b) {
if (this->IsFloat() && b->IsFloat()){
if (this->IsFloat()){
if (b->IsFloat()){
return new FloatEvalValue(this->GetFloatValue() * b->GetFloatValue());
} else if (this->IsFloat()){
} else{
return new FloatEvalValue(this->GetFloatValue() * b->GetIntegerValue());
} else if (b->IsFloat()){
}
} else {
if (b->IsFloat()){
return new FloatEvalValue(this->GetIntegerValue() * b->GetFloatValue());
} else{
return new IntegerEvalValue(this->GetIntegerValue() * b->GetIntegerValue());
}
}
}
NumericEvalValue *NumericEvalValue::operator/(NumericEvalValue *b) {
if (this->IsFloat() && b->IsFloat()){
if (this->IsFloat()){
if (b->IsFloat()){
return new FloatEvalValue(this->GetFloatValue() / b->GetFloatValue());
} else if (this->IsFloat()){
} else{
return new FloatEvalValue(this->GetFloatValue() / b->GetIntegerValue());
} else if (b->IsFloat()){
}
} else {
if (b->IsFloat()){
return new FloatEvalValue(this->GetIntegerValue() / b->GetFloatValue());
} else{
return new IntegerEvalValue(this->GetIntegerValue() / b->GetIntegerValue());
}
}
}