Differences From Artifact [b1982608cc]:
- File src/OFBitSetCharacterSet.m — part of check-in [7413a728a7] at 2024-04-03 02:16:03 on branch trunk — Change license to LGPLv3 only (user: js, size: 1921) [annotate] [blame] [check-ins using] [more...]
To Artifact [9db9ebbd67]:
- File
src/OFBitSetCharacterSet.m
— part of check-in
[96f946d7ad]
at
2024-05-09 10:21:24
on branch trunk
— Use unsigned long for bit sets
This should be more efficient on some architectures.
As a nice side effect, this is also what Linux does in some userspace
APIs, so after this change, these macros can be used for this as well
(and Linux interestingly does not provide similar macros in the
userspace headers). (user: js, size: 1999) [annotate] [blame] [check-ins using] [more...]
︙ | ︙ | |||
38 39 40 41 42 43 44 | void *pool = objc_autoreleasePoolPush(); const OFUnichar *characters = string.characters; size_t length = string.length; for (size_t i = 0; i < length; i++) { OFUnichar c = characters[i]; | | | | | > | > | | | | | 38 39 40 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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | void *pool = objc_autoreleasePoolPush(); const OFUnichar *characters = string.characters; size_t length = string.length; for (size_t i = 0; i < length; i++) { OFUnichar c = characters[i]; if (c / OF_ULONG_BIT >= _size) { size_t newSize; if (UINT32_MAX - c < 1) @throw [OFOutOfRangeException exception]; newSize = OFRoundUpToPowerOf2(OF_ULONG_BIT, c + 1) / OF_ULONG_BIT; _bitSet = OFResizeMemory(_bitSet, newSize, sizeof(unsigned long)); memset(_bitSet + _size, '\0', (newSize - _size) * sizeof(unsigned long)); _size = newSize; } OFBitSetSet(_bitSet, c); } objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; } return self; } - (void)dealloc { OFFreeMemory(_bitSet); [super dealloc]; } - (bool)characterIsMember: (OFUnichar)character { if (character / OF_ULONG_BIT >= _size) return false; return OFBitSetIsSet(_bitSet, character); } @end |