aboutsummaryrefslogtreecommitdiff
path: root/novena-eim.h
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2016-09-09 22:28:22 -0400
committerRob Austein <sra@hactrn.net>2016-09-09 22:28:22 -0400
commit52bafc94397795e196aa516df044994692f4705f (patch)
treecf2902e30be32df79be41edd470f4c11fe17ef97 /novena-eim.h
parentd56ce9ab6cfd874b0bbcba204b33af4e7e762517 (diff)
Portable fix for ks_find() fencepost error.
Binary search of an array is a notorious example of a simple algorithm which is hard to get exactly right. The variant we're using is nice because it automatically computes the correct insertion point when a key doesn't exist, but runs into one of the portability corner cases of signed integer arithemtic in C. Rather than leave a landmine waiting to explode if somebody builds this code on a platform where (-1 >> 1) != -1, we test for the corner case explictly and accept the miniscule performance hit (which will be lost in other noise anyway).
Diffstat (limited to 'novena-eim.h')
0 files changed, 0 insertions, 0 deletions
20'>120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187