[gnome-calculator/wip/ricotz/gcalc: 6/7] gcalc: Remove superfluous casts in GConstant
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calculator/wip/ricotz/gcalc: 6/7] gcalc: Remove superfluous casts in GConstant
- Date: Mon, 7 Oct 2019 18:17:46 +0000 (UTC)
commit e30b7e628200143f336972039b458ac290d8341e
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Mon Oct 7 20:13:02 2019 +0200
gcalc: Remove superfluous casts in GConstant
gcalc/gcalc-gconstant.vala | 38 ++++++++++++++++++++------------------
1 file changed, 20 insertions(+), 18 deletions(-)
---
diff --git a/gcalc/gcalc-gconstant.vala b/gcalc/gcalc-gconstant.vala
index 88ea0bc3..0a60c536 100644
--- a/gcalc/gcalc-gconstant.vala
+++ b/gcalc/gcalc-gconstant.vala
@@ -54,63 +54,64 @@ public class GCalc.GConstant : GExpression, Constant {
r.set_zero ();
_complex.set_mpreal (r);
}
+
public Constant add (Constant c)
requires (c is GConstant)
{
var res = MPC.Complex (1000);
var p1 = MPC.Complex (1000);
- p1.set ((c as GConstant).get_complex ());
+ p1.set (((GConstant) c).get_complex ());
res.add (_complex, p1);
- var nc = new GConstant.internal_complex (res);
- return nc as Constant;
+ return new GConstant.internal_complex (res);
}
+
public Constant subtract (Constant c)
requires (c is GConstant)
{
var res = MPC.Complex (1000);
var p1 = MPC.Complex (1000);
- p1.set ((c as GConstant).get_complex ());
+ p1.set (((GConstant) c).get_complex ());
res.subtract (_complex, p1);
- var nc = new GConstant.internal_complex (res);
- return nc as Constant;
+ return new GConstant.internal_complex (res);
}
+
public Constant multiply (Constant c)
requires (c is GConstant)
{
var res = MPC.Complex (1000);
var p1 = MPC.Complex (1000);
- p1.set ((c as GConstant).get_complex ());
+ p1.set (((GConstant) c).get_complex ());
res.multiply (_complex, p1);
- var nc = new GConstant.internal_complex (res);
- return nc as Constant;
+ return new GConstant.internal_complex (res);
}
+
public Constant divide (Constant c)
requires (c is GConstant)
{
var res = MPC.Complex (1000);
var p1 = MPC.Complex (1000);
- p1.set ((c as GConstant).get_complex ());
+ p1.set (((GConstant) c).get_complex ());
res.divide (_complex, p1);
- var nc = new GConstant.internal_complex (res);
- return nc as Constant;
+ return new GConstant.internal_complex (res);
}
+
public Constant neg ()
{
var res = MPC.Complex (1000);
res.neg (_complex);
- var nc = new GConstant.internal_complex (res);
- return nc as Constant;
+ return new GConstant.internal_complex (res);
}
+
public Constant pow (Constant c)
requires (c is GConstant)
{
var res = MPC.Complex (1000);
var p1 = MPC.Complex (1000);
- p1.set ((c as GConstant).get_complex ());
+ p1.set (((GConstant) c).get_complex ());
res.power (_complex, p1);
- var nc = new GConstant.internal_complex (res);
- return nc as Constant;
+ return new GConstant.internal_complex (res);
}
+
// Expression interface
public override string to_string () {
if (imag () != 0.0) {
@@ -118,8 +119,9 @@ public class GCalc.GConstant : GExpression, Constant {
}
return "%g".printf (real ());
}
+
public override Result solve () {
- return new GResult (this) as Result;
+ return new GResult (this);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]