Browse code

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

- faster dropping of last branch

Daniel-Constantin Mierla authored on 05/06/2015 09:42:06
Showing 1 changed files
... ...
@@ -122,14 +122,14 @@ int drop_sip_branch(int idx)
122 122
 		return 0;
123 123
 	if(idx<0 && (int)nr_branches+idx<0)
124 124
 		return 0;
125
+	if(idx<0)
126
+		idx += nr_branches;
125 127
 	/* last branch */
126 128
 	if(idx==nr_branches-1)
127 129
 	{
128 130
 		nr_branches--;
129 131
 		return 0;
130 132
 	}
131
-	if(idx<0)
132
-		idx = nr_branches+idx;
133 133
 	/* shift back one position */
134 134
 	for(; idx<nr_branches-1; idx++)
135 135
 		memcpy(&branches[idx], &branches[idx+1], sizeof(branch_t));