Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] Optimization of getarrvalue()



On Nov 9, 11:42am, Peter Stephenson wrote:
}
} +    } else if (v->end <= v->start) {
} +        s = arrdup_max(s, 1);
} +        s[0] = NULL;

Might as well make it obvious?

diff --git a/Src/params.c b/Src/params.c
index ef72cba..6736aa5 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -2293,10 +2293,9 @@ getarrvalue(Value v)
 
     /* Null if 1) array too short, 2) index still negative */
     if (arrlen_lt(s, v->start) || v->start < 0) {
-	s = arrdup(nular);
+	s = arrdup_max(nular, 1);
     } else if (v->end <= v->start) {
-        s = arrdup_max(s, 1);
-        s[0] = NULL;
+        s = arrdup_max(nular, 0);
     } else {
         /* Copy to a point before the end of the source array:
          * arrdup_max will copy at most v->end - v->start elements,



Messages sorted by: Reverse Date, Date, Thread, Author