- if (is->length == 0) {
- pos = 0;
- } else {
- /* Check for the case where we know the insert position */
- if (value > INTSET_GET(is,is->length-1)) {
- pos = is->length;
- } else if (value < INTSET_GET(is,0)) {
- pos = 0;
- } else {
- /* Abort if the value is already present in the set */
- if (intsetSearch(is,value,&pos)) {
- if (success) *success = 0;
- return is;
- }
- }
+ /* Abort if the value is already present in the set.
+ * This call will populate "pos" with the right position to insert
+ * the value when it cannot be found. */
+ if (intsetSearch(is,value,&pos)) {
+ if (success) *success = 0;
+ return is;