The original code (rather oddly) interprets a length of zero in
subvec() to mean "the whole vector". Melchior showed a use case (removal of the first element from a vector) where getting a zero-length subvector is actually desired. And since I can't come up with a good reason for why the "feature" was there in the first place, out it goes...
This commit is contained in:
parent
6e973e07f4
commit
9d6c0dc580
@ -69,7 +69,7 @@ static naRef subvec(naContext c, naRef me, int argc, naRef* args)
|
|||||||
len = (int)nlen.num;
|
len = (int)nlen.num;
|
||||||
if(!naIsVector(v) || start < 0 || start >= naVec_size(v) || len < 0)
|
if(!naIsVector(v) || start < 0 || start >= naVec_size(v) || len < 0)
|
||||||
return naNil();
|
return naNil();
|
||||||
if(len == 0 || len > naVec_size(v) - start) len = naVec_size(v) - start;
|
if(len > naVec_size(v) - start) len = naVec_size(v) - start;
|
||||||
result = naNewVector(c);
|
result = naNewVector(c);
|
||||||
naVec_setsize(result, len);
|
naVec_setsize(result, len);
|
||||||
for(i=0; i<len; i++)
|
for(i=0; i<len; i++)
|
||||||
|
Loading…
Reference in New Issue
Block a user