Code

* Remove unused variables
[inkscape.git] / src / display / curve.cpp
index 3ea4e60dfd7756fa51b65a2256805a21d906d952..3e491a2b8a67114ee040b66e2e1bdfd5af44a242 100644 (file)
@@ -61,7 +61,6 @@ sp_curve_new_sized(gint length)
     curve->end = 0;
     curve->length = length;
     curve->substart = 0;
-    curve->sbpath = false;
     curve->hascpt = false;
     curve->posSet = false;
     curve->moving = false;
@@ -80,62 +79,35 @@ sp_curve_new_from_bpath(NArtBpath *bpath)
 {
     g_return_val_if_fail(bpath != NULL, NULL);
 
-    if (!sp_bpath_good(bpath)) {
-        NArtBpath *new_bpath = sp_bpath_clean(bpath);
-        if (new_bpath == NULL) {
-            return NULL;
-        }
-        nr_free(bpath);
-        bpath = new_bpath;
-    }
-
-    SPCurve *curve = g_new(SPCurve, 1);
-
-    curve->refcount = 1;
-    curve->_bpath = bpath;
-    curve->length = sp_bpath_length(bpath);
-    curve->end = curve->length - 1;
-    gint i = curve->end;
-    for (; i > 0; i--)
-        if ((curve->_bpath[i].code == NR_MOVETO) ||
-            (curve->_bpath[i].code == NR_MOVETO_OPEN))
-            break;
-    curve->substart = i;
-    curve->sbpath = false;
-    curve->hascpt = false;
-    curve->posSet = false;
-    curve->moving = false;
-    curve->closed = sp_bpath_closed(bpath);
-
+    SPCurve *curve = sp_curve_new_from_foreign_bpath(bpath);
+    nr_free(bpath);
     return curve;
 }
 
-/** 
- * Construct an SPCurve from read-only, static storage.
+/**
+ * Convert const NArtBpath array to SPCurve.
  *
- *  We could treat read-onliness and staticness (i.e. can't call free on bpath) as orthogonal
- *  attributes, but at the time of writing we have only one caller.
+ * \return new SPCurve, or NULL if the curve was not created for some reason.
  */
-SPCurve *
-sp_curve_new_from_static_bpath(NArtBpath const *bpath)
+SPCurve *sp_curve_new_from_foreign_bpath(NArtBpath const bpath[])
 {
     g_return_val_if_fail(bpath != NULL, NULL);
 
-    bool sbpath;
+    NArtBpath *new_bpath;
     if (!sp_bpath_good(bpath)) {
-        NArtBpath *new_bpath = sp_bpath_clean(bpath);
+        new_bpath = sp_bpath_clean(bpath);
         g_return_val_if_fail(new_bpath != NULL, NULL);
-        sbpath = false;
-        bpath = new_bpath;
     } else {
-        sbpath = true;
+        unsigned const len = sp_bpath_length(bpath);
+        new_bpath = nr_new(NArtBpath, len);
+        memcpy(new_bpath, bpath, len * sizeof(NArtBpath));
     }
 
     SPCurve *curve = g_new(SPCurve, 1);
 
     curve->refcount = 1;
-    curve->_bpath = const_cast<NArtBpath *>(bpath);
-    curve->length = sp_bpath_length(bpath);
+    curve->_bpath = new_bpath;
+    curve->length = sp_bpath_length(new_bpath);
     curve->end = curve->length - 1;
     gint i = curve->end;
     for (; i > 0; i--)
@@ -143,38 +115,10 @@ sp_curve_new_from_static_bpath(NArtBpath const *bpath)
             (curve->_bpath[i].code == NR_MOVETO_OPEN))
             break;
     curve->substart = i;
-    curve->sbpath = sbpath;
     curve->hascpt = false;
     curve->posSet = false;
     curve->moving = false;
-    curve->closed = sp_bpath_closed(bpath);
-
-    return curve;
-}
-
-/**
- * Convert const NArtBpath array to SPCurve.
- *
- * \return new SPCurve, or NULL if the curve was not created for some reason.
- */
-SPCurve *sp_curve_new_from_foreign_bpath(NArtBpath const bpath[])
-{
-    g_return_val_if_fail(bpath != NULL, NULL);
-
-    NArtBpath *new_bpath;
-    if (!sp_bpath_good(bpath)) {
-        new_bpath = sp_bpath_clean(bpath);
-        g_return_val_if_fail(new_bpath != NULL, NULL);
-    } else {
-        unsigned const len = sp_bpath_length(bpath);
-        new_bpath = nr_new(NArtBpath, len);
-        memcpy(new_bpath, bpath, len * sizeof(NArtBpath));
-    }
-
-    SPCurve *curve = sp_curve_new_from_bpath(new_bpath);
-
-    if (!curve)
-        nr_free(new_bpath);
+    curve->closed = sp_bpath_closed(new_bpath);
 
     return curve;
 }
@@ -207,7 +151,7 @@ sp_curve_unref(SPCurve *curve)
     curve->refcount -= 1;
 
     if (curve->refcount < 1) {
-        if ((!curve->sbpath) && (curve->_bpath)) {
+        if (curve->_bpath) {
             nr_free(curve->_bpath);
         }
         g_free(curve);
@@ -330,7 +274,6 @@ static void
 tmpl_curve_transform(SPCurve *const curve, M const &m)
 {
     g_return_if_fail(curve != NULL);
-    g_return_if_fail(!curve->sbpath);
 
     for (gint i = 0; i < curve->end; i++) {
         NArtBpath *p = curve->_bpath + i;
@@ -381,7 +324,6 @@ void
 sp_curve_reset(SPCurve *curve)
 {
     g_return_if_fail(curve != NULL);
-    g_return_if_fail(!curve->sbpath);
 
     curve->_bpath->code = NR_END;
     curve->end = 0;
@@ -410,7 +352,6 @@ void
 sp_curve_moveto(SPCurve *curve, NR::Point const &p)
 {
     g_return_if_fail(curve != NULL);
-    g_return_if_fail(!curve->sbpath);
     g_return_if_fail(!curve->moving);
 
     curve->substart = curve->end;
@@ -435,7 +376,6 @@ void
 sp_curve_lineto(SPCurve *curve, gdouble x, gdouble y)
 {
     g_return_if_fail(curve != NULL);
-    g_return_if_fail(!curve->sbpath);
     g_return_if_fail(curve->hascpt);
 
     if (curve->moving) {
@@ -486,7 +426,6 @@ void
 sp_curve_lineto_moving(SPCurve *curve, gdouble x, gdouble y)
 {
     g_return_if_fail(curve != NULL);
-    g_return_if_fail(!curve->sbpath);
     g_return_if_fail(curve->hascpt);
 
     if (curve->moving) {
@@ -554,7 +493,6 @@ void
 sp_curve_curveto(SPCurve *curve, gdouble x0, gdouble y0, gdouble x1, gdouble y1, gdouble x2, gdouble y2)
 {
     g_return_if_fail(curve != NULL);
-    g_return_if_fail(!curve->sbpath);
     g_return_if_fail(curve->hascpt);
     g_return_if_fail(!curve->moving);
 
@@ -604,7 +542,6 @@ void
 sp_curve_closepath(SPCurve *curve)
 {
     g_return_if_fail(curve != NULL);
-    g_return_if_fail(!curve->sbpath);
     g_return_if_fail(curve->hascpt);
     g_return_if_fail(!curve->posSet);
     g_return_if_fail(!curve->moving);
@@ -648,7 +585,6 @@ void
 sp_curve_closepath_current(SPCurve *curve)
 {
     g_return_if_fail(curve != NULL);
-    g_return_if_fail(!curve->sbpath);
     g_return_if_fail(curve->hascpt);
     g_return_if_fail(!curve->posSet);
     g_return_if_fail(!curve->closed);