Differences From Artifact [9d6ca887c3]:
- File src/OFString+XMLUnescaping.m — part of check-in [8892ae9fcc] at 2012-07-12 01:28:46 on branch trunk — Don't access isa directly. (user: js, size: 6798) [annotate] [blame] [check-ins using]
To Artifact [c2d8e053db]:
- File
src/OFString+XMLUnescaping.m
— part of check-in
[1255f3a11a]
at
2012-08-10 20:08:24
on branch trunk
— Directly use the runtime's autorelease pools.
This greatly improves performance, as it gets rid of the overhead of
OFAutoreleasePool. (user: js, size: 6776) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
15 16 17 18 19 20 21 | */ #include "config.h" #include <string.h> #import "OFString.h" | < > | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | */ #include "config.h" #include <string.h> #import "OFString.h" #import "OFInvalidEncodingException.h" #import "autorelease.h" #import "macros.h" int _OFString_XMLUnescaping_reference; static OF_INLINE OFString* parse_numeric_entity(const char *entity, size_t length) { |
︙ | ︙ | |||
127 128 129 130 131 132 133 | withEncoding: OF_STRING_ENCODING_ASCII length: 1]; else if (entityLength == 3 && !memcmp(entity, "amp", 3)) [ret appendCString: "&" withEncoding: OF_STRING_ENCODING_ASCII length: 1]; else if (entity[0] == '#') { | | | | | | | | 127 128 129 130 131 132 133 134 135 136 137 138 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 164 165 166 167 168 169 170 171 | withEncoding: OF_STRING_ENCODING_ASCII length: 1]; else if (entityLength == 3 && !memcmp(entity, "amp", 3)) [ret appendCString: "&" withEncoding: OF_STRING_ENCODING_ASCII length: 1]; else if (entity[0] == '#') { void *pool; OFString *tmp; pool = objc_autoreleasePoolPush(); tmp = parse_numeric_entity(entity, entityLength); if (tmp == nil) @throw [OFInvalidEncodingException exceptionWithClass: [self class]]; [ret appendString: tmp]; objc_autoreleasePoolPop(pool); } else if (delegate != nil) { void *pool; OFString *n, *tmp; pool = objc_autoreleasePoolPush(); n = [OFString stringWithUTF8String: entity length: entityLength]; tmp = [delegate string: self containsUnknownEntityNamed: n]; if (tmp == nil) @throw [OFInvalidEncodingException exceptionWithClass: [self class]]; [ret appendString: tmp]; objc_autoreleasePoolPop(pool); } else @throw [OFInvalidEncodingException exceptionWithClass: [self class]]; last = i + 1; inEntity = NO; } |
︙ | ︙ | |||
230 231 232 233 234 235 236 | withEncoding: OF_STRING_ENCODING_ASCII length: 1]; else if (entityLength == 3 && !memcmp(entity, "amp", 3)) [ret appendCString: "&" withEncoding: OF_STRING_ENCODING_ASCII length: 1]; else if (entity[0] == '#') { | | | | | | | | 230 231 232 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 | withEncoding: OF_STRING_ENCODING_ASCII length: 1]; else if (entityLength == 3 && !memcmp(entity, "amp", 3)) [ret appendCString: "&" withEncoding: OF_STRING_ENCODING_ASCII length: 1]; else if (entity[0] == '#') { void *pool; OFString *tmp; pool = objc_autoreleasePoolPush(); tmp = parse_numeric_entity(entity, entityLength); if (tmp == nil) @throw [OFInvalidEncodingException exceptionWithClass: [self class]]; [ret appendString: tmp]; objc_autoreleasePoolPop(pool); } else { void *pool; OFString *entityString, *tmp; pool = objc_autoreleasePoolPush(); entityString = [OFString stringWithUTF8String: entity length: entityLength]; tmp = block(self, entityString); if (tmp == nil) @throw [OFInvalidEncodingException exceptionWithClass: [self class]]; [ret appendString: tmp]; objc_autoreleasePoolPop(pool); } last = i + 1; inEntity = NO; } } |
︙ | ︙ |