Comment: | Make use of fast enumeration
Now that we require GCC >= 4.6 anyway, there's no more reason to not use |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
6b13727ce0b7073e4e1dbd7109172be9 |
User & Date: | js on 2015-11-29 14:02:11 |
Other Links: | manifest | tags |
2015-11-29
| ||
14:20 | Clean up optional protocols check-in: ba62f00fac user: js tags: trunk | |
14:02 | Make use of fast enumeration check-in: 6b13727ce0 user: js tags: trunk | |
11:43 | Make properties a requirement and clean up code check-in: 48980f2297 user: js tags: trunk | |
Modified src/OFArray.m from [ac5ec4c8c9] to [2be2e1c20f].
︙ | ︙ | |||
557 558 559 560 561 562 563 | } - (OFString*)OF_JSONRepresentationWithOptions: (int)options depth: (size_t)depth { OFMutableString *JSON = [OFMutableString stringWithString: @"["]; void *pool = objc_autoreleasePoolPush(); | < < | | | 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 | } - (OFString*)OF_JSONRepresentationWithOptions: (int)options depth: (size_t)depth { OFMutableString *JSON = [OFMutableString stringWithString: @"["]; void *pool = objc_autoreleasePoolPush(); size_t i, count = [self count]; if (options & OF_JSON_REPRESENTATION_PRETTY) { OFMutableString *indentation = [OFMutableString string]; for (i = 0; i < depth; i++) [indentation appendString: @"\t"]; [JSON appendString: @"\n"]; i = 0; for (id object in self) { void *pool2 = objc_autoreleasePoolPush(); [JSON appendString: indentation]; [JSON appendString: @"\t"]; [JSON appendString: [object OF_JSONRepresentationWithOptions: options depth: depth + 1]]; if (++i < count) [JSON appendString: @",\n"]; else [JSON appendString: @"\n"]; objc_autoreleasePoolPop(pool2); } [JSON appendString: indentation]; } else { i = 0; for (id object in self) { void *pool2 = objc_autoreleasePoolPush(); [JSON appendString: [object OF_JSONRepresentationWithOptions: options depth: depth + 1]]; if (++i < count) |
︙ | ︙ | |||
617 618 619 620 621 622 623 | } - (OFDataArray*)messagePackRepresentation { OFDataArray *data; size_t i, count; void *pool; | < < | 615 616 617 618 619 620 621 622 623 624 625 626 627 628 | } - (OFDataArray*)messagePackRepresentation { OFDataArray *data; size_t i, count; void *pool; data = [OFDataArray dataArray]; count = [self count]; if (count <= 15) { uint8_t tmp = 0x90 | ((uint8_t)count & 0xF); [data addItem: &tmp]; |
︙ | ︙ | |||
646 647 648 649 650 651 652 | count: sizeof(tmp)]; } else @throw [OFOutOfRangeException exception]; pool = objc_autoreleasePoolPush(); i = 0; | | < | 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 | count: sizeof(tmp)]; } else @throw [OFOutOfRangeException exception]; pool = objc_autoreleasePoolPush(); i = 0; for (id object in self) { void *pool2 = objc_autoreleasePoolPush(); OFDataArray *child; i++; child = [object messagePackRepresentation]; [data addItems: [child items] |
︙ | ︙ | |||
751 752 753 754 755 756 757 | - (OFEnumerator*)objectEnumerator { return [[[OFArrayEnumerator alloc] initWithArray: self mutationsPtr: NULL] autorelease]; } | | | 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 | - (OFEnumerator*)objectEnumerator { return [[[OFArrayEnumerator alloc] initWithArray: self mutationsPtr: NULL] autorelease]; } #ifdef OF_HAVE_BLOCKS - (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block { size_t i = 0; bool stop = false; for (id object in self) { block(object, i++, &stop); |
︙ | ︙ |
Modified src/OFArray_adjacent.m from [8679aa9a9b] to [2d053d23e3].
︙ | ︙ | |||
163 164 165 166 167 168 169 | - initWithSerialization: (OFXMLElement*)element { self = [self init]; @try { void *pool = objc_autoreleasePoolPush(); | < < | | < < | 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | - initWithSerialization: (OFXMLElement*)element { self = [self init]; @try { void *pool = objc_autoreleasePoolPush(); if ((![[element name] isEqual: @"OFArray"] && ![[element name] isEqual: @"OFMutableArray"]) || ![[element namespace] isEqual: OF_SERIALIZATION_NS]) @throw [OFInvalidArgumentException exception]; for (OFXMLElement *child in [element elementsForNamespace: OF_SERIALIZATION_NS]) { void *pool2 = objc_autoreleasePoolPush(); id object; object = [child objectByDeserializing]; [_array addItem: &object]; [object retain]; |
︙ | ︙ |
Modified src/OFCountedSet.m from [0df520b24c] to [9e3f055893].
︙ | ︙ | |||
139 140 141 142 143 144 145 | OF_UNRECOGNIZED_SELECTOR } - (OFString*)description { OFMutableString *ret; void *pool; | < < < | | 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 | OF_UNRECOGNIZED_SELECTOR } - (OFString*)description { OFMutableString *ret; void *pool; size_t i, count = [self count]; if (count == 0) return @"{()}"; ret = [OFMutableString stringWithString: @"{(\n"]; pool = objc_autoreleasePoolPush(); i = 0; for (id object in self) { void *pool2 = objc_autoreleasePoolPush(); [ret appendString: object]; [ret appendFormat: @": %zu", [self countForObject: object]]; if (++i < count) [ret appendString: @",\n"]; |
︙ | ︙ | |||
188 189 190 191 192 193 194 | return [[OFCountedSet alloc] initWithSet: self]; } - (OFXMLElement*)XMLElementBySerializing { void *pool = objc_autoreleasePoolPush(); OFXMLElement *element; | < < < | < | 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | return [[OFCountedSet alloc] initWithSet: self]; } - (OFXMLElement*)XMLElementBySerializing { void *pool = objc_autoreleasePoolPush(); OFXMLElement *element; element = [OFXMLElement elementWithName: @"OFCountedSet" namespace: OF_SERIALIZATION_NS]; for (id <OFSerialization> object in self) { void *pool2 = objc_autoreleasePoolPush(); OFXMLElement *objectElement; OFString *count; count = [OFString stringWithFormat: @"%zu", |
︙ | ︙ | |||
240 241 242 243 244 245 246 | - (void)minusSet: (OFSet*)set { void *pool = objc_autoreleasePoolPush(); if ([set isKindOfClass: [OFCountedSet class]]) { OFCountedSet *countedSet = (OFCountedSet*)set; | < < | | < | < < < < < | | < | < < < | 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | - (void)minusSet: (OFSet*)set { void *pool = objc_autoreleasePoolPush(); if ([set isKindOfClass: [OFCountedSet class]]) { OFCountedSet *countedSet = (OFCountedSet*)set; for (id object in countedSet) { size_t i, count = [countedSet countForObject: object]; for (i = 0; i < count; i++) [self removeObject: object]; } } else for (id object in set) [self removeObject: object]; objc_autoreleasePoolPop(pool); } - (void)unionSet: (OFSet*)set { void *pool = objc_autoreleasePoolPush(); if ([set isKindOfClass: [OFCountedSet class]]) { OFCountedSet *countedSet = (OFCountedSet*)set; for (id object in countedSet) { size_t i, count = [countedSet countForObject: object]; for (i = 0; i < count; i++) [self addObject: object]; } } else for (id object in set) [self addObject: object]; objc_autoreleasePoolPop(pool); } @end |
Modified src/OFCountedSet_hashtable.m from [cd05f3d64e] to [87ab020669].
︙ | ︙ | |||
41 42 43 44 45 46 47 | self = [self init]; @try { void *pool = objc_autoreleasePoolPush(); if ([set isKindOfClass: [OFCountedSet class]]) { OFCountedSet *countedSet = (OFCountedSet*)countedSet; | < < < | | < | < < < | 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | self = [self init]; @try { void *pool = objc_autoreleasePoolPush(); if ([set isKindOfClass: [OFCountedSet class]]) { OFCountedSet *countedSet = (OFCountedSet*)countedSet; for (id object in countedSet) { size_t i, count; count = [countedSet countForObject: object]; for (i = 0; i < count; i++) [self addObject: object]; } } else for (id object in set) [self addObject: object]; objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; } |
︙ | ︙ | |||
132 133 134 135 136 137 138 | - initWithSerialization: (OFXMLElement*)element { self = [self init]; @try { void *pool = objc_autoreleasePoolPush(); | < < < > | | < < < | 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | - initWithSerialization: (OFXMLElement*)element { self = [self init]; @try { void *pool = objc_autoreleasePoolPush(); if (![[element name] isEqual: @"OFCountedSet"] || ![[element namespace] isEqual: OF_SERIALIZATION_NS]) @throw [OFInvalidArgumentException exception]; for (OFXMLElement *objectElement in [element elementsForName: @"object" namespace: OF_SERIALIZATION_NS]) { void *pool2 = objc_autoreleasePoolPush(); OFXMLElement *object; OFXMLAttribute *count_; size_t count; object = [[objectElement elementsForNamespace: OF_SERIALIZATION_NS] firstObject]; |
︙ | ︙ |
Modified src/OFDictionary.m from [fae9385bda] to [f9d2ed8c00].
︙ | ︙ | |||
297 298 299 300 301 302 303 | return [[OFMutableDictionary alloc] initWithDictionary: self]; } - (bool)isEqual: (id)object { OFDictionary *otherDictionary; void *pool; | | | > > | | | < < > | 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 | return [[OFMutableDictionary alloc] initWithDictionary: self]; } - (bool)isEqual: (id)object { OFDictionary *otherDictionary; void *pool; OFEnumerator *keyEnumerator, *objectEnumerator; id key; if (![object isKindOfClass: [OFDictionary class]]) return false; otherDictionary = object; if ([otherDictionary count] != [self count]) return false; pool = objc_autoreleasePoolPush(); keyEnumerator = [self keyEnumerator]; objectEnumerator = [self objectEnumerator]; while ((key = [keyEnumerator nextObject]) != nil && (object = [objectEnumerator nextObject]) != nil) { id otherObject = [otherDictionary objectForKey: key]; if (otherObject == nil || ![otherObject isEqual: object]) { objc_autoreleasePoolPop(pool); return false; } } objc_autoreleasePoolPop(pool); return true; } - (bool)containsObject: (id)object { void *pool; OFEnumerator *enumerator; id currentObject; if (object == nil) return false; pool = objc_autoreleasePoolPush(); enumerator = [self objectEnumerator]; while ((currentObject = [enumerator nextObject]) != nil) { if ([currentObject isEqual: object]) { objc_autoreleasePoolPop(pool); return true; } } |
︙ | ︙ | |||
360 361 362 363 364 365 366 | OFEnumerator *enumerator; id currentObject; if (object == nil) return false; pool = objc_autoreleasePoolPush(); | < > < < < | < < | 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 | OFEnumerator *enumerator; id currentObject; if (object == nil) return false; pool = objc_autoreleasePoolPush(); enumerator = [self objectEnumerator]; while ((currentObject = [enumerator nextObject]) != nil) { if (currentObject == object) { objc_autoreleasePoolPop(pool); return true; } } objc_autoreleasePoolPop(pool); return false; } - (OFArray*)allKeys { OFMutableArray *ret = [OFMutableArray arrayWithCapacity: [self count]]; for (id key in self) [ret addObject: key]; [ret makeImmutable]; return ret; } - (OFArray*)allObjects { OFMutableArray *ret = [OFMutableArray arrayWithCapacity: [self count]]; void *pool = objc_autoreleasePoolPush(); |
︙ | ︙ | |||
425 426 427 428 429 430 431 | - (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state objects: (id*)objects count: (int)count_ { OF_UNRECOGNIZED_SELECTOR } | | < < | 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 | - (int)countByEnumeratingWithState: (of_fast_enumeration_state_t*)state objects: (id*)objects count: (int)count_ { OF_UNRECOGNIZED_SELECTOR } #ifdef OF_HAVE_BLOCKS - (void)enumerateKeysAndObjectsUsingBlock: (of_dictionary_enumeration_block_t)block { bool stop = false; for (id key in self) { block(key, [self objectForKey: key], &stop); if (stop) break; } } - (OFDictionary*)mappedDictionaryUsingBlock: (of_dictionary_map_block_t)block { OFMutableDictionary *new = [OFMutableDictionary dictionary]; [self enumerateKeysAndObjectsUsingBlock: ^ (id key, id object, bool *stop) { [new setObject: block(key, object) |
︙ | ︙ | |||
477 478 479 480 481 482 483 | return new; } #endif - (uint32_t)hash { void *pool = objc_autoreleasePoolPush(); | | > | > | | | 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 | return new; } #endif - (uint32_t)hash { void *pool = objc_autoreleasePoolPush(); OFEnumerator *keyEnumerator = [self keyEnumerator]; OFEnumerator *objectEnumerator = [self objectEnumerator]; id key, object; uint32_t hash = 0; while ((key = [keyEnumerator nextObject]) != nil && (object = [objectEnumerator nextObject]) != nil) { hash += [key hash]; hash += [object hash]; } objc_autoreleasePoolPop(pool); return hash; } |
︙ | ︙ |
Modified src/OFFileManager.m from [737527b063] to [a3021efc2a].
︙ | ︙ | |||
246 247 248 249 250 251 252 | exceptionWithPath: path errNo: errno]; } - (void)createDirectoryAtPath: (OFString*)path createParents: (bool)createParents { | < < | < < < | < < | | < < | 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 | exceptionWithPath: path errNo: errno]; } - (void)createDirectoryAtPath: (OFString*)path createParents: (bool)createParents { OFString *currentPath = nil; if (!createParents) { [self createDirectoryAtPath: path]; return; } if (path == nil) @throw [OFInvalidArgumentException exception]; for (OFString *component in [path pathComponents]) { void *pool = objc_autoreleasePoolPush(); if (currentPath != nil) currentPath = [currentPath stringByAppendingPathComponent: component]; else currentPath = component; if ([currentPath length] > 0 && ![self directoryExistsAtPath: currentPath]) [self createDirectoryAtPath: currentPath]; [currentPath retain]; objc_autoreleasePoolPop(pool); [currentPath autorelease]; } } - (OFArray*)contentsOfDirectoryAtPath: (OFString*)path { OFMutableArray *files; #ifndef OF_WINDOWS of_string_encoding_t encoding; |
︙ | ︙ | |||
591 592 593 594 595 596 597 | @throw [OFCopyItemFailedException exceptionWithSourcePath: source destinationPath: destination errNo: errno]; if (S_ISDIR(s.st_mode)) { OFArray *contents; | < < | 582 583 584 585 586 587 588 589 590 591 592 593 594 595 | @throw [OFCopyItemFailedException exceptionWithSourcePath: source destinationPath: destination errNo: errno]; if (S_ISDIR(s.st_mode)) { OFArray *contents; @try { [self createDirectoryAtPath: destination]; #ifdef OF_HAVE_CHMOD [self changePermissionsOfItemAtPath: destination permissions: s.st_mode]; #endif |
︙ | ︙ | |||
618 619 620 621 622 623 624 | exceptionWithSourcePath: source destinationPath: destination errNo: [e errNo]]; @throw e; } | | < | 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 | exceptionWithSourcePath: source destinationPath: destination errNo: [e errNo]]; @throw e; } for (OFString *item in contents) { void *pool2 = objc_autoreleasePoolPush(); OFString *sourcePath, *destinationPath; sourcePath = [source stringByAppendingPathComponent: item]; destinationPath = [destination stringByAppendingPathComponent: item]; |
︙ | ︙ | |||
788 789 790 791 792 793 794 | if (of_lstat(path, &s) != 0) @throw [OFRemoveItemFailedException exceptionWithPath: path errNo: errno]; if (S_ISDIR(s.st_mode)) { OFArray *contents; | < < | < | 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 | if (of_lstat(path, &s) != 0) @throw [OFRemoveItemFailedException exceptionWithPath: path errNo: errno]; if (S_ISDIR(s.st_mode)) { OFArray *contents; @try { contents = [self contentsOfDirectoryAtPath: path]; } @catch (id e) { /* * Only convert exceptions to * OFRemoveItemFailedException that have an errNo * property. This covers all I/O related exceptions * from the operations used to remove an item, all * others should be left as is. */ if ([e respondsToSelector: @selector(errNo)]) @throw [OFRemoveItemFailedException exceptionWithPath: path errNo: [e errNo]]; @throw e; } for (OFString *item in contents) { void *pool2 = objc_autoreleasePoolPush(); [self removeItemAtPath: [path stringByAppendingPathComponent: item]]; objc_autoreleasePoolPop(pool2); } |
︙ | ︙ |
Modified src/OFINICategory.m from [db5fef86d0] to [ab1f7455cf].
︙ | ︙ | |||
188 189 190 191 192 193 194 | return [self stringForKey: key defaultValue: nil]; } - (OFString*)stringForKey: (OFString*)key defaultValue: (OFString*)defaultValue { | < < | < < | | | < < < < < < < | 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 | return [self stringForKey: key defaultValue: nil]; } - (OFString*)stringForKey: (OFString*)key defaultValue: (OFString*)defaultValue { for (id line in _lines) { OFINICategory_Pair *pair; if (![line isKindOfClass: [OFINICategory_Pair class]]) continue; pair = line; if ([pair->_key isEqual: key]) return [[pair->_value copy] autorelease]; } return defaultValue; } - (intmax_t)integerForKey: (OFString*)key defaultValue: (intmax_t)defaultValue { |
︙ | ︙ | |||
298 299 300 301 302 303 304 | return ret; } - (OFArray*)arrayForKey: (OFString*)key { OFMutableArray *ret = [OFMutableArray array]; void *pool = objc_autoreleasePoolPush(); | < < | | 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 | return ret; } - (OFArray*)arrayForKey: (OFString*)key { OFMutableArray *ret = [OFMutableArray array]; void *pool = objc_autoreleasePoolPush(); for (id line in _lines) { OFINICategory_Pair *pair; if (![line isKindOfClass: [OFINICategory_Pair class]]) continue; pair = line; |
︙ | ︙ | |||
324 325 326 327 328 329 330 | return ret; } - (void)setString: (OFString*)string forKey: (OFString*)key { void *pool = objc_autoreleasePoolPush(); | < < | > > > > | | | > > > > > > | 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 | return ret; } - (void)setString: (OFString*)string forKey: (OFString*)key { void *pool = objc_autoreleasePoolPush(); OFINICategory_Pair *pair; for (id line in _lines) { if (![line isKindOfClass: [OFINICategory_Pair class]]) continue; pair = line; if ([pair->_key isEqual: key]) { OFString *old = pair->_value; pair->_value = [string copy]; [old release]; objc_autoreleasePoolPop(pool); return; } } pair = [[[OFINICategory_Pair alloc] init] autorelease]; pair->_key = nil; pair->_value = nil; @try { pair->_key = [key copy]; pair->_value = [string copy]; [_lines addObject: pair]; } @catch (id e) { [pair->_key release]; [pair->_value release]; @throw e; } objc_autoreleasePoolPop(pool); } - (void)setInteger: (intmax_t)integer forKey: (OFString*)key { |
︙ | ︙ | |||
397 398 399 400 401 402 403 | objc_autoreleasePoolPop(pool); } - (void)setArray: (OFArray*)array forKey: (OFString*)key { void *pool; | < < < | | 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 | objc_autoreleasePoolPop(pool); } - (void)setArray: (OFArray*)array forKey: (OFString*)key { void *pool; OFMutableArray *pairs; id const *lines; size_t i, count; bool replaced; if ([array count] == 0) { [self removeValueForKey: key]; return; } pool = objc_autoreleasePoolPush(); pairs = [OFMutableArray arrayWithCapacity: [array count]]; for (id object in array) { OFINICategory_Pair *pair; if (![object isKindOfClass: [OFString class]]) @throw [OFInvalidArgumentException exception]; pair = [[[OFINICategory_Pair alloc] init] autorelease]; pair->_key = [key copy]; |
︙ | ︙ | |||
497 498 499 500 501 502 503 | objc_autoreleasePoolPop(pool); } - (bool)OF_writeToStream: (OFStream*)stream encoding: (of_string_encoding_t)encoding first: (bool)first { | < < < | < | 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 | objc_autoreleasePoolPop(pool); } - (bool)OF_writeToStream: (OFStream*)stream encoding: (of_string_encoding_t)encoding first: (bool)first { if ([_lines count] == 0) return false; if (first) [stream writeFormat: @"[%@]\n", _name]; else [stream writeFormat: @"\n[%@]\n", _name]; for (id line in _lines) { if ([line isKindOfClass: [OFINICategory_Comment class]]) { OFINICategory_Comment *comment = line; [stream writeLine: comment->_comment]; } else if ([line isKindOfClass: [OFINICategory_Pair class]]) { OFINICategory_Pair *pair = line; OFString *key = escapeString(pair->_key); OFString *value = escapeString(pair->_value); |
︙ | ︙ |
Modified src/OFINIFile.m from [7499aebd7d] to [754d91375c].
︙ | ︙ | |||
102 103 104 105 106 107 108 | [super dealloc]; } - (OFINICategory*)categoryForName: (OFString*)name { void *pool = objc_autoreleasePoolPush(); | < | | 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | [super dealloc]; } - (OFINICategory*)categoryForName: (OFString*)name { void *pool = objc_autoreleasePoolPush(); OFINICategory *category; for (category in _categories) { if ([[category name] isEqual: name]) { OFINICategory *ret = [category retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } |
︙ | ︙ | |||
185 186 187 188 189 190 191 | - (void)writeToFile: (OFString*)path encoding: (of_string_encoding_t)encoding { void *pool = objc_autoreleasePoolPush(); OFFile *file = [OFFile fileWithPath: path mode: @"w"]; | < < | | 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | - (void)writeToFile: (OFString*)path encoding: (of_string_encoding_t)encoding { void *pool = objc_autoreleasePoolPush(); OFFile *file = [OFFile fileWithPath: path mode: @"w"]; bool first = true; for (OFINICategory *category in _categories) if ([category OF_writeToStream: file encoding: encoding first: first]) first = false; objc_autoreleasePoolPop(pool); } @end |
Modified src/OFList.m from [a0868f6c97] to [7c70cf8600].
︙ | ︙ | |||
38 39 40 41 42 43 44 | - initWithSerialization: (OFXMLElement*)element { self = [self init]; @try { void *pool = objc_autoreleasePoolPush(); | < < | | < | 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | - initWithSerialization: (OFXMLElement*)element { self = [self init]; @try { void *pool = objc_autoreleasePoolPush(); if (![[element name] isEqual: [self className]] || ![[element namespace] isEqual: OF_SERIALIZATION_NS]) @throw [OFInvalidArgumentException exception]; for (OFXMLElement *child in [element elementsForNamespace: OF_SERIALIZATION_NS]) { void *pool2 = objc_autoreleasePoolPush(); [self appendObject: [child objectByDeserializing]]; objc_autoreleasePoolPop(pool2); } |
︙ | ︙ |
Modified src/OFMutableArray.m from [b9da7d0ecc] to [0b551de582].
︙ | ︙ | |||
217 218 219 220 221 222 223 | { OF_UNRECOGNIZED_SELECTOR } - (void)insertObjectsFromArray: (OFArray*)array atIndex: (size_t)index { | < < | < | < < < | < < < | 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | { OF_UNRECOGNIZED_SELECTOR } - (void)insertObjectsFromArray: (OFArray*)array atIndex: (size_t)index { size_t i = 0; for (id object in array) [self insertObject: object atIndex: index + i++]; } - (void)replaceObjectAtIndex: (size_t)index withObject: (id)object { OF_UNRECOGNIZED_SELECTOR } |
︙ | ︙ |
Modified src/OFMutableDictionary.m from [670510655b] to [d75be996d7].
︙ | ︙ | |||
180 181 182 183 184 185 186 | { OF_UNRECOGNIZED_SELECTOR } - (void)removeAllObjects { void *pool = objc_autoreleasePoolPush(); | < < < | | 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | { OF_UNRECOGNIZED_SELECTOR } - (void)removeAllObjects { void *pool = objc_autoreleasePoolPush(); for (id key in [self allKeys]) [self removeObjectForKey: key]; objc_autoreleasePoolPop(pool); } - copy { |
︙ | ︙ |
Modified src/OFMutableSet.m from [472c53bec1] to [0ec52f3f83].
︙ | ︙ | |||
140 141 142 143 144 145 146 | - (void)removeObject: (id)object { OF_UNRECOGNIZED_SELECTOR } - (void)minusSet: (OFSet*)set { | < < | < < < < < < | < < < | < < < < < | 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 188 | - (void)removeObject: (id)object { OF_UNRECOGNIZED_SELECTOR } - (void)minusSet: (OFSet*)set { for (id object in set) [self removeObject: object]; } - (void)intersectSet: (OFSet*)set { void *pool = objc_autoreleasePoolPush(); size_t count = [self count]; id *cArray; cArray = [self allocMemoryWithSize: sizeof(id) count: count]; @try { size_t i; i = 0; for (id object in self) { assert(i < count); cArray[i++] = object; } for (i = 0; i < count; i++) if (![set containsObject: cArray[i]]) [self removeObject: cArray[i]]; } @finally { [self freeMemory: cArray]; } objc_autoreleasePoolPop(pool); } - (void)unionSet: (OFSet*)set { for (id object in set) [self addObject: object]; } - (void)makeImmutable { } @end |
Modified src/OFProcess.m from [b8e8f16191] to [3256a71833].
︙ | ︙ | |||
226 227 228 229 230 231 232 | objc_autoreleasePoolPop(pool); #else SECURITY_ATTRIBUTES sa; PROCESS_INFORMATION pi; STARTUPINFOW si; void *pool; OFMutableString *argumentsString; | < < | 226 227 228 229 230 231 232 233 234 235 236 237 238 239 | objc_autoreleasePoolPop(pool); #else SECURITY_ATTRIBUTES sa; PROCESS_INFORMATION pi; STARTUPINFOW si; void *pool; OFMutableString *argumentsString; of_char16_t *argumentsCopy; size_t length; sa.nLength = sizeof(sa); sa.bInheritHandle = TRUE; sa.lpSecurityDescriptor = NULL; |
︙ | ︙ | |||
275 276 277 278 279 280 281 | withString: @"\\\""]; if ([argumentsString containsString: @" "]) { [argumentsString prependString: @"\""]; [argumentsString appendString: @"\""]; } | | < | 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | withString: @"\\\""]; if ([argumentsString containsString: @" "]) { [argumentsString prependString: @"\""]; [argumentsString appendString: @"\""]; } for (OFString *argument in arguments) { OFMutableString *tmp = [[argument mutableCopy] autorelease]; bool containsSpaces = [tmp containsString: @" "]; [argumentsString appendString: @" "]; if (containsSpaces) |
︙ | ︙ |
Modified src/OFSet.m from [2b7acb7d08] to [c1fc0fd847].
︙ | ︙ | |||
244 245 246 247 248 249 250 | return [otherSet isSubsetOfSet: self]; } - (uint32_t)hash { void *pool = objc_autoreleasePoolPush(); | < < | < < < | | 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | return [otherSet isSubsetOfSet: self]; } - (uint32_t)hash { void *pool = objc_autoreleasePoolPush(); uint32_t hash = 0; for (id object in self) hash += [object hash]; objc_autoreleasePoolPop(pool); return hash; } - (OFString*)description { void *pool; OFMutableString *ret; size_t i, count = [self count]; if (count == 0) return @"{()}"; ret = [OFMutableString stringWithString: @"{(\n"]; pool = objc_autoreleasePoolPush(); i = 0; for (id object in self) { void *pool2 = objc_autoreleasePoolPush(); [ret appendString: [object description]]; if (++i < count) [ret appendString: @",\n"]; |
︙ | ︙ | |||
306 307 308 309 310 311 312 | - mutableCopy { return [[OFMutableSet alloc] initWithSet: self]; } - (bool)isSubsetOfSet: (OFSet*)set { | < < | < < < | < < < < < < < | < < < | < < < < < < < < | < | 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 | - mutableCopy { return [[OFMutableSet alloc] initWithSet: self]; } - (bool)isSubsetOfSet: (OFSet*)set { for (id object in self) if (![set containsObject: object]) return false; return true; } - (bool)intersectsSet: (OFSet*)set { for (id object in self) if ([set containsObject: object]) return true; return false; } - (OFXMLElement*)XMLElementBySerializing { void *pool = objc_autoreleasePoolPush(); OFXMLElement *element; if ([self isKindOfClass: [OFMutableSet class]]) element = [OFXMLElement elementWithName: @"OFMutableSet" namespace: OF_SERIALIZATION_NS]; else element = [OFXMLElement elementWithName: @"OFSet" namespace: OF_SERIALIZATION_NS]; for (id <OFSerialization> object in self) { void *pool2 = objc_autoreleasePoolPush(); [element addChild: [object XMLElementBySerializing]]; objc_autoreleasePoolPop(pool2); } |
︙ | ︙ | |||
427 428 429 430 431 432 433 | void *pool = objc_autoreleasePoolPush(); id ret = [[[self objectEnumerator] nextObject] retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } | | < < | 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 | void *pool = objc_autoreleasePoolPush(); id ret = [[[self objectEnumerator] nextObject] retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } #ifdef OF_HAVE_BLOCKS - (void)enumerateObjectsUsingBlock: (of_set_enumeration_block_t)block { bool stop = false; for (id object in self) { block(object, &stop); if (stop) break; } } - (OFSet*)filteredSetUsingBlock: (of_set_filter_block_t)block { OFMutableSet *ret = [OFMutableSet set]; [self enumerateObjectsUsingBlock: ^ (id object, bool *stop) { if (block(object)) [ret addObject: object]; |
︙ | ︙ |
Modified src/OFSet_hashtable.m from [fcbd1c81f4] to [1eaa048921].
︙ | ︙ | |||
96 97 98 99 100 101 102 | [self release]; @throw e; } self = [self initWithCapacity: count]; @try { | < < | < < < < < | 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | [self release]; @throw e; } self = [self initWithCapacity: count]; @try { for (id object in set) [_mapTable setValue: (void*)1 forKey: object]; } @catch (id e) { [self release]; @throw e; } return self; } |
︙ | ︙ | |||
131 132 133 134 135 136 137 | [self release]; @throw e; } self = [self initWithCapacity: count]; @try { | < < | < < < < < | 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | [self release]; @throw e; } self = [self initWithCapacity: count]; @try { for (id object in array) [_mapTable setValue: (void*)1 forKey: object]; } @catch (id e) { [self release]; @throw e; } return self; } |
︙ | ︙ | |||
207 208 209 210 211 212 213 | - initWithSerialization: (OFXMLElement*)element { self = [self init]; @try { void *pool = objc_autoreleasePoolPush(); | < < | | < | 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 | - initWithSerialization: (OFXMLElement*)element { self = [self init]; @try { void *pool = objc_autoreleasePoolPush(); if ((![[element name] isEqual: @"OFSet"] && ![[element name] isEqual: @"OFMutableSet"]) || ![[element namespace] isEqual: OF_SERIALIZATION_NS]) @throw [OFInvalidArgumentException exception]; for (OFXMLElement *child in [element elementsForNamespace: OF_SERIALIZATION_NS]) { void *pool2 = objc_autoreleasePoolPush(); [_mapTable setValue: (void*)1 forKey: [child objectByDeserializing]]; objc_autoreleasePoolPop(pool2); } |
︙ | ︙ |
Modified src/OFString.m from [0176c8e382] to [01f9bb127a].
︙ | ︙ | |||
652 653 654 655 656 657 658 | encoding: encoding] autorelease]; } #endif + (OFString*)pathWithComponents: (OFArray*)components { OFMutableString *ret = [OFMutableString string]; | | | | | < | | < | > | < | 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 | encoding: encoding] autorelease]; } #endif + (OFString*)pathWithComponents: (OFArray*)components { OFMutableString *ret = [OFMutableString string]; bool first = true; for (OFString *component in components) { if (!first) [ret appendString: OF_PATH_DELIMITER_STRING]; [ret appendString: component]; first = false; } return ret; } - init { if (object_getClass(self) == [OFString class]) { |
︙ | ︙ |
Modified src/OFThreadPool.m from [ceb8630ad0] to [e4818c31b0].
︙ | ︙ | |||
291 292 293 294 295 296 297 | } return self; } - (void)dealloc { | < < | < < < | 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 | } return self; } - (void)dealloc { [_queueCondition lock]; @try { [_countCondition lock]; @try { for (OFThreadPoolThread *thread in _threads) thread->_terminate = true; } @finally { [_countCondition unlock]; } [_queueCondition broadcast]; } @finally { [_queueCondition unlock]; } [_threads release]; [_queue release]; [_queueCondition release]; [_countCondition release]; [super dealloc]; |
︙ | ︙ |
Modified src/OFXMLElement.m from [1f70933951] to [767015e338].
︙ | ︙ | |||
317 318 319 320 321 322 323 | if ((_attributes != nil && ![_attributes isKindOfClass: [OFMutableArray class]]) || (_namespaces != nil && ![_namespaces isKindOfClass: [OFMutableDictionary class]]) || (_children != nil && ![_children isKindOfClass: [OFMutableArray class]])) @throw [OFInvalidArgumentException exception]; | | < | < | 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 | if ((_attributes != nil && ![_attributes isKindOfClass: [OFMutableArray class]]) || (_namespaces != nil && ![_namespaces isKindOfClass: [OFMutableDictionary class]]) || (_children != nil && ![_children isKindOfClass: [OFMutableArray class]])) @throw [OFInvalidArgumentException exception]; for (object in _attributes) if (![object isKindOfClass: [OFXMLAttribute class]]) @throw [OFInvalidArgumentException exception]; keyEnumerator = [_namespaces keyEnumerator]; objectEnumerator = [_namespaces objectEnumerator]; while ((key = [keyEnumerator nextObject]) != nil && (object = [objectEnumerator nextObject]) != nil) if (![key isKindOfClass: [OFString class]] || ![object isKindOfClass: [OFString class]]) @throw [OFInvalidArgumentException exception]; for (object in _children) if (![object isKindOfClass: [OFXMLNode class]]) @throw [OFInvalidArgumentException exception]; if (_namespaces == nil) _namespaces = [[OFMutableDictionary alloc] init]; [_namespaces |
︙ | ︙ | |||
916 917 918 919 920 921 922 | [_children insertObject: child atIndex: index]; } - (void)insertChildren: (OFArray*)children atIndex: (size_t)index { | < < | < < < < | 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 | [_children insertObject: child atIndex: index]; } - (void)insertChildren: (OFArray*)children atIndex: (size_t)index { for (OFXMLNode *node in children) if ([node isKindOfClass: [OFXMLAttribute class]]) @throw [OFInvalidArgumentException exception]; [_children insertObjectsFromArray: children atIndex: index]; } - (void)removeChild: (OFXMLNode*)child { if ([child isKindOfClass: [OFXMLAttribute class]]) @throw [OFInvalidArgumentException exception]; |
︙ | ︙ |
Modified utils/ofhash/OFHash.m from [59a725be71] to [d5afdd7b11].
︙ | ︙ | |||
69 70 71 72 73 74 75 | } @implementation OFHash - (void)applicationDidFinishLaunching { OFArray OF_GENERIC(OFString*) *arguments = [OFApplication arguments]; id <OFHash> hash; | < | | < < | > > > > > > > | 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | } @implementation OFHash - (void)applicationDidFinishLaunching { OFArray OF_GENERIC(OFString*) *arguments = [OFApplication arguments]; id <OFHash> hash; bool first = true; int exitStatus = 0; if ([arguments count] < 2) help(); if ((hash = hashForName([arguments firstObject])) == nil) help(); for (OFString *path in arguments) { void *pool; OFStream *file; const uint8_t *digest; size_t i, digestSize; if (first) { first = false; continue; } pool = objc_autoreleasePoolPush(); if ([path isEqual: @"-"]) file = of_stdin; else { @try { file = [OFFile fileWithPath: path mode: @"rb"]; } @catch (OFOpenItemFailedException *e) { |
︙ | ︙ |
Modified utils/ofzip/OFZIP.m from [6492307736] to [d383d3b508].
︙ | ︙ | |||
250 251 252 253 254 255 256 | } return archive; } - (void)listFilesInArchive: (OFZIPArchive*)archive { | < | < < < < | 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | } return archive; } - (void)listFilesInArchive: (OFZIPArchive*)archive { for (OFZIPArchiveEntry *entry in [archive entries]) { void *pool = objc_autoreleasePoolPush(); [of_stdout writeLine: [entry fileName]]; if (_outputLevel >= 1) { OFString *date = [[entry modificationDate] localDateStringWithFormat: @"%Y-%m-%d %H:%M:%S"]; |
︙ | ︙ | |||
309 310 311 312 313 314 315 | } } - (void)extractFiles: (OFArray OF_GENERIC(OFString*)*)files fromArchive: (OFZIPArchive*)archive { OFFileManager *fileManager = [OFFileManager defaultManager]; | < < | | < < | | < < | | 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 | } } - (void)extractFiles: (OFArray OF_GENERIC(OFString*)*)files fromArchive: (OFZIPArchive*)archive { OFFileManager *fileManager = [OFFileManager defaultManager]; bool all = ([files count] == 0); OFMutableSet OF_GENERIC(OFString*) *missing = [OFMutableSet setWithArray: files]; for (OFZIPArchiveEntry *entry in [archive entries]) { void *pool = objc_autoreleasePoolPush(); OFString *fileName = [entry fileName]; OFString *outFileName = [fileName stringByStandardizingPath]; OFArray OF_GENERIC(OFString*) *pathComponents; OFString *directory; OFStream *stream; OFFile *output; char buffer[BUFFER_SIZE]; uint64_t written = 0, size = [entry uncompressedSize]; int_fast8_t percent = -1, newPercent; if (!all && ![files containsObject: fileName]) |
︙ | ︙ | |||
350 351 352 353 354 355 356 | fileName]; _exitStatus = 1; goto outer_loop_end; } pathComponents = [outFileName pathComponents]; | | < | 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 | fileName]; _exitStatus = 1; goto outer_loop_end; } pathComponents = [outFileName pathComponents]; for (OFString *component in pathComponents) { if ([component isEqual: OF_PATH_PARENT_DIRECTORY]) { [of_stderr writeFormat: @"Refusing to extract %@!\n", fileName]; _exitStatus = 1; goto outer_loop_end; } |
︙ | ︙ | |||
476 477 478 479 480 481 482 | fileName]; outer_loop_end: objc_autoreleasePoolPop(pool); } if ([missing count] > 0) { | < | < < < | 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 | fileName]; outer_loop_end: objc_autoreleasePoolPop(pool); } if ([missing count] > 0) { for (OFString *file in missing) [of_stderr writeFormat: @"File %@ is not in the archive!\n", file]; _exitStatus = 1; } } @end |