瀏覽代碼

core: resolve negative index for dset before checking if it is last branch

- faster dropping of last branch
Daniel-Constantin Mierla 10 年之前
父節點
當前提交
f8f40045e1
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2 2
      dset.c

+ 2 - 2
dset.c

@@ -122,14 +122,14 @@ int drop_sip_branch(int idx)
 		return 0;
 	if(idx<0 && (int)nr_branches+idx<0)
 		return 0;
+	if(idx<0)
+		idx += nr_branches;
 	/* last branch */
 	if(idx==nr_branches-1)
 	{
 		nr_branches--;
 		return 0;
 	}
-	if(idx<0)
-		idx = nr_branches+idx;
 	/* shift back one position */
 	for(; idx<nr_branches-1; idx++)
 		memcpy(&branches[idx], &branches[idx+1], sizeof(branch_t));