Differences From Artifact [c74680827d]:
- File
src/OFMutableDictionary.m
— part of check-in
[3bccfadcc1]
at
2010-06-01 18:00:12
on branch trunk
— Fix a very nasty typo in OFMutableDictionary.
This typo would prevent termination in the very rare case that the last
bucket is already used. (user: js, size: 5237) [annotate] [blame] [check-ins using] [more...]
To Artifact [0791cedf2b]:
- File src/OFMutableDictionary.m — part of check-in [eea73f8d37] at 2010-08-25 11:33:58 on branch trunk — -[setObject:forKey:] and -[removeObjectForKey:] now return void. (user: js, size: 5170) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
75 76 77 78 79 80 81 | } [self freeMemory: data]; data = newdata; size = newsize; } | | | | 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | } [self freeMemory: data]; data = newdata; size = newsize; } - (void)setObject: (OFObject*)obj forKey: (OFObject <OFCopying>*)key { uint32_t i, hash, last; id old; if (key == nil || obj == nil) @throw [OFInvalidArgumentException newWithClass: isa selector: _cmd]; |
︙ | ︙ | |||
155 156 157 158 159 160 161 | b->key = key; b->object = obj; b->hash = hash; data[i] = b; count++; | | < | | < < < > | | < < > | < < | 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 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | b->key = key; b->object = obj; b->hash = hash; data[i] = b; count++; return; } old = data[i]->object; data[i]->object = [obj retain]; [old release]; } - (void)removeObjectForKey: (OFObject*)key { uint32_t i, hash, last; if (key == nil) @throw [OFInvalidArgumentException newWithClass: isa selector: _cmd]; hash = [key hash]; last = size; for (i = hash & (size - 1); i < last && data[i] != NULL; i++) { if (data[i] == DELETED) continue; if ([data[i]->key isEqual: key]) { [data[i]->key release]; [data[i]->object release]; [self freeMemory: data[i]]; data[i] = DELETED; count--; mutations++; [self _resizeForCount: count]; return; } } if (i < last) return; /* In case the last bucket is already used */ last = hash & (size - 1); for (i = 0; i < last && data[i] != NULL; i++) { if (data[i] == DELETED) continue; if ([data[i]->key isEqual: key]) { [data[i]->key release]; [data[i]->object release]; [self freeMemory: data[i]]; data[i] = DELETED; count--; mutations++; [self _resizeForCount: count]; return; } } } - copy { return [[OFDictionary alloc] initWithDictionary: self]; } |
︙ | ︙ |