Overview
Comment: | Fix shadowed variable and duplicate code |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
c0fad4d24c02cb21d81e03e9279eda39 |
User & Date: | js on 2022-12-26 01:19:17 |
Other Links: | manifest | tags |
Context
2022-12-26
| ||
01:54 | OFMutableArray: Fix constness check-in: 9fd8b1301a user: js tags: trunk | |
01:19 | Fix shadowed variable and duplicate code check-in: c0fad4d24c user: js tags: trunk | |
2022-12-25
| ||
19:11 | Add missing nullable check-in: 8461a50c3a user: js tags: trunk | |
Changes
Modified src/OFMutableArray.m from [221f6c44e1] to [5b457e1838].
︙ | ︙ | |||
28 29 30 31 32 33 34 | static struct { Class isa; } placeholder; @interface OFMutableArrayPlaceholder: OFMutableArray @end | < < < < < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | static struct { Class isa; } placeholder; @interface OFMutableArrayPlaceholder: OFMutableArray @end static void quicksort(OFMutableArray *array, size_t left, size_t right, OFCompareFunction compare, void *context, OFArraySortOptions options) { OFComparisonResult ascending, descending; if (options & OFArraySortDescending) { ascending = OFOrderedDescending; descending = OFOrderedAscending; |
︙ | ︙ | |||
122 123 124 125 126 127 128 | if (compare([array objectAtIndex: i], pivot, context) == descending) [array exchangeObjectAtIndex: i withObjectAtIndex: right]; if (i > 0) | | | | 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | if (compare([array objectAtIndex: i], pivot, context) == descending) [array exchangeObjectAtIndex: i withObjectAtIndex: right]; if (i > 0) quicksort(array, left, i - 1, compare, context, options); left = i + 1; } } @implementation OFMutableArrayPlaceholder - (instancetype)init |
︙ | ︙ | |||
408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 | } } - (void)sort { [self sortUsingSelector: @selector(compare:) options: 0]; } - (void)sortUsingSelector: (SEL)selector options: (OFArraySortOptions)options { size_t count = self.count; if (count == 0 || count == 1) return; | > > > > > > > > > > > | | | < | 353 354 355 356 357 358 359 360 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 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 | } } - (void)sort { [self sortUsingSelector: @selector(compare:) options: 0]; } static OFComparisonResult selectorCompare(id left, id right, void *context) { SEL selector = context; OFComparisonResult (*comparator)(id, SEL, id) = (OFComparisonResult (*)(id, SEL, id)) [left methodForSelector: selector]; return comparator(left, selector, right); } - (void)sortUsingSelector: (SEL)selector options: (OFArraySortOptions)options { size_t count = self.count; if (count == 0 || count == 1) return; quicksort(self, 0, count - 1, selectorCompare, selector, options); } - (void)sortUsingFunction: (OFCompareFunction)compare context: (void *)context options: (OFArraySortOptions)options { size_t count = self.count; if (count == 0 || count == 1) return; quicksort(self, 0, count - 1, compare, context, options); } #ifdef OF_HAVE_BLOCKS static OFComparisonResult blockCompare(id left, id right, void *context) { OFComparator block = (OFComparator)context; return block(left, right); } - (void)sortUsingComparator: (OFComparator)comparator options: (OFArraySortOptions)options { size_t count = self.count; if (count == 0 || count == 1) return; quicksort(self, 0, count - 1, blockCompare, comparator, options); } #endif - (void)reverse { size_t i, j, count = self.count; |
︙ | ︙ |