|
24 | 24 | // want ARC to insert 'objc_retainAutoreleasedReturnValue' and the necessary
|
25 | 25 | // markers for the hand-off.
|
26 | 26 |
|
| 27 | +// On i386 we use an autorelease pool to prevent leaking. |
| 28 | +#if defined(__i386__) |
| 29 | +#define AUTORELEASEPOOL @autoreleasepool |
| 30 | +#else |
| 31 | +// On other platforms we rely on autorelease return optimization. |
| 32 | +#define AUTORELEASEPOOL |
| 33 | +#endif |
| 34 | + |
27 | 35 | SWIFT_CC(swift) SWIFT_RUNTIME_STDLIB_INTERFACE
|
28 | 36 | size_t swift_stdlib_NSStringHashValue(NSString *NS_RELEASES_ARGUMENT str,
|
29 | 37 | bool isASCII) {
|
30 |
| - return isASCII ? str.hash : str.decomposedStringWithCanonicalMapping.hash; |
| 38 | + AUTORELEASEPOOL { |
| 39 | + return isASCII ? str.hash : str.decomposedStringWithCanonicalMapping.hash; |
| 40 | + } |
31 | 41 | }
|
32 | 42 |
|
33 | 43 | SWIFT_CC(swift) SWIFT_RUNTIME_STDLIB_INTERFACE
|
34 | 44 | size_t
|
35 | 45 | swift_stdlib_NSStringHashValuePointer(void *opaque, bool isASCII) {
|
36 | 46 | NSString __unsafe_unretained *str =
|
37 | 47 | (__bridge NSString __unsafe_unretained *)opaque;
|
38 |
| - return isASCII ? str.hash : str.decomposedStringWithCanonicalMapping.hash; |
| 48 | + AUTORELEASEPOOL { |
| 49 | + return isASCII ? str.hash : str.decomposedStringWithCanonicalMapping.hash; |
| 50 | + } |
39 | 51 | }
|
40 | 52 |
|
41 | 53 | SWIFT_CC(swift) SWIFT_RUNTIME_STDLIB_INTERFACE
|
42 | 54 | NS_RETURNS_RETAINED NSString *
|
43 | 55 | swift_stdlib_NSStringLowercaseString(NSString *NS_RELEASES_ARGUMENT str) {
|
44 |
| - return str.lowercaseString; |
| 56 | + AUTORELEASEPOOL { |
| 57 | + return str.lowercaseString; |
| 58 | + } |
45 | 59 | }
|
46 | 60 |
|
47 | 61 | SWIFT_CC(swift) SWIFT_RUNTIME_STDLIB_INTERFACE
|
48 | 62 | NS_RETURNS_RETAINED NSString *
|
49 | 63 | swift_stdlib_NSStringUppercaseString(NSString *NS_RELEASES_ARGUMENT str) {
|
50 |
| - return str.uppercaseString; |
| 64 | + AUTORELEASEPOOL { |
| 65 | + return str.uppercaseString; |
| 66 | + } |
51 | 67 | }
|
52 | 68 |
|
53 | 69 | #endif
|
0 commit comments