[librsvg] path: Use correct comparison



commit 0a8bdb0a5348625ed0ab3d6225c09df97149982a
Author: Benjamin Otte <otte redhat com>
Date:   Fri Nov 6 00:09:17 2015 +0100

    path: Use correct comparison
    
    We were doing nothing for i == 2.
    
    Also, the code was written in such a way that this error was hard to
    spot. Why would you start your elseif nesting with the > 2 condition?
    And most of all: Why would you not use a simple else clause?

 rsvg-path.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/rsvg-path.c b/rsvg-path.c
index e21b084..954f9f8 100644
--- a/rsvg-path.c
+++ b/rsvg-path.c
@@ -346,14 +346,14 @@ rsvg_parse_path_default_xy (RSVGParsePathCtx * ctx, int n_params)
 
     if (ctx->rel) {
         for (i = ctx->param; i < n_params; i++) {
-            if (i > 2)
-                ctx->params[i] = ctx->params[i - 2];
+            /* we shouldn't get 0 here (usually ctx->param > 0 as
+               precondition) */
+            if (i == 0)
+                ctx->params[i] = ctx->cp.point.x;
             else if (i == 1)
                 ctx->params[i] = ctx->cp.point.y;
-            else if (i == 0)
-                /* we shouldn't get here (usually ctx->param > 0 as
-                   precondition) */
-                ctx->params[i] = ctx->cp.point.x;
+            else
+                ctx->params[i] = ctx->params[i - 2];
         }
     } else {
         for (i = ctx->param; i < n_params; i++)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]