Remove redundant null checks in string concat

This commit is contained in:
altrisi authored and GitHub committed 2022-10-02 18:11:15 +02:00
1 parent 3247b83272
commit be1cb6888a
1 file changed
+3 -9
+3 -9
View File
@@ -66,19 +66,13 @@ public abstract class Value implements Comparable<Value>, Cloneable
public abstract boolean getBoolean(); public abstract boolean getBoolean();
public Value add(Value o) { public Value add(Value o) {
String lstr = this.getString();
if (o instanceof FormattedTextValue) if (o instanceof FormattedTextValue)
{ {
return FormattedTextValue.combine(this, o); return FormattedTextValue.combine(this, o);
} }
if (lstr == null) // null String leftStr = this.getString();
return new StringValue(o.getString()); String rightStr = o.getString();
String rstr = o.getString(); return new StringValue(leftStr + rightStr);
if (rstr == null)
{
return new StringValue(lstr);
}
return new StringValue(lstr+rstr);
} }
public Value subtract(Value v) public Value subtract(Value v)
{ {