aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objective-c/RxLibrary
diff options
context:
space:
mode:
authorGravatar Jorge Canizales <jcanizales@google.com>2016-08-24 18:47:51 -0700
committerGravatar GitHub <noreply@github.com>2016-08-24 18:47:51 -0700
commitea5325c484571cb114946b6e1d06e4a26284e198 (patch)
treeec550c79241d58fd35069d344b6ef9b9c6cec354 /src/objective-c/RxLibrary
parent19ea0cffd7ba3df686ed05671f9ed35b8e9fa830 (diff)
Avoid static initialization of the kIdentity block
Unlike other Objective-C objects, there's no hard reason why the compiler wouldn't be able to initialize a block statically (as it does with NSString literals). And it certainly doesn't complain about it (like it does with other object initializers). But as I haven't been able to find confirmation of this, and we're seeing a weird crash occur near this code, let's play it safe.
Diffstat (limited to 'src/objective-c/RxLibrary')
-rw-r--r--src/objective-c/RxLibrary/transformations/GRXMappingWriter.m8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/objective-c/RxLibrary/transformations/GRXMappingWriter.m b/src/objective-c/RxLibrary/transformations/GRXMappingWriter.m
index f3242e4fa9..6ee1545d25 100644
--- a/src/objective-c/RxLibrary/transformations/GRXMappingWriter.m
+++ b/src/objective-c/RxLibrary/transformations/GRXMappingWriter.m
@@ -33,10 +33,6 @@
#import "GRXMappingWriter.h"
-static id (^kIdentity)(id value) = ^id(id value) {
- return value;
-};
-
@interface GRXForwardingWriter () <GRXWriteable>
@end
@@ -51,7 +47,9 @@ static id (^kIdentity)(id value) = ^id(id value) {
// Designated initializer
- (instancetype)initWithWriter:(GRXWriter *)writer map:(id (^)(id value))map {
if ((self = [super initWithWriter:writer])) {
- _map = map ?: kIdentity;
+ _map = map ?: ^id(id value) {
+ return value;
+ };
}
return self;
}