Differences From Artifact [2047693bf0]:
- File
src/OFDate.m
— part of check-in
[ff3a60cc12]
at
2024-04-28 08:36:55
on branch trunk
— Use @synchronized over OFMutex in a few places
These places are not super performance critical and the code becomes a
lot more readable.Actually using @synchronized in ObjFW itself is also a good motivation
to optimize it further. (user: js, size: 17918) [annotate] [blame] [check-ins using] [more...]
To Artifact [b2a6d429a4]:
- File src/OFDate.m — part of check-in [f16bccc7b3] at 2024-04-29 21:42:33 on branch trunk — Properly hide private symbols (user: js, size: 17923) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
410 411 412 413 414 415 416 | format: (OFString *)format { void *pool = objc_autoreleasePoolPush(); const char *UTF8String = string.UTF8String; struct tm tm = { .tm_isdst = -1 }; short tz = 0; | | | | | 410 411 412 413 414 415 416 417 418 419 420 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 | format: (OFString *)format { void *pool = objc_autoreleasePoolPush(); const char *UTF8String = string.UTF8String; struct tm tm = { .tm_isdst = -1 }; short tz = 0; if (_OFStrPTime(UTF8String, format.UTF8String, &tm, &tz) != UTF8String + string.UTF8StringLength) @throw [OFInvalidFormatException exception]; objc_autoreleasePoolPop(pool); return [self initWithTimeIntervalSince1970: tmAndTzToTime(&tm, tz)]; } - (instancetype)initWithLocalDateString: (OFString *)string format: (OFString *)format { void *pool = objc_autoreleasePoolPush(); const char *UTF8String = string.UTF8String; struct tm tm = { .tm_isdst = -1 }; /* * _OFStrPTime() can never set this to SHRT_MAX, no matter what is * passed to it, so this is a safe way to figure out if the date * contains a time zone. */ short tz = SHRT_MAX; OFTimeInterval seconds; if (_OFStrPTime(UTF8String, format.UTF8String, &tm, &tz) != UTF8String + string.UTF8StringLength) @throw [OFInvalidFormatException exception]; if (tz == SHRT_MAX) { #ifdef OF_WINDOWS if (_mktime64FuncPtr != NULL) { if ((seconds = _mktime64FuncPtr(&tm)) == -1) |
︙ | ︙ | |||
688 689 690 691 692 693 694 | } # endif #endif pageSize = [OFSystemInfo pageSize]; buffer = OFAllocMemory(1, pageSize); @try { | | | 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 | } # endif #endif pageSize = [OFSystemInfo pageSize]; buffer = OFAllocMemory(1, pageSize); @try { if (_OFStrFTime(buffer, pageSize, format.UTF8String, &tm, 0) == 0) @throw [OFOutOfRangeException exception]; ret = [OFString stringWithUTF8String: buffer]; } @finally { OFFreeMemory(buffer); } |
︙ | ︙ | |||
737 738 739 740 741 742 743 | } # endif #endif pageSize = [OFSystemInfo pageSize]; buffer = OFAllocMemory(1, pageSize); @try { | | | 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 | } # endif #endif pageSize = [OFSystemInfo pageSize]; buffer = OFAllocMemory(1, pageSize); @try { if (_OFStrFTime(buffer, pageSize, format.UTF8String, &tm, 0) == 0) @throw [OFOutOfRangeException exception]; ret = [OFString stringWithUTF8String: buffer]; } @finally { OFFreeMemory(buffer); } |
︙ | ︙ |