From 29f55d5655dc095205f8d02e01dcd0e2583c39eb Mon Sep 17 00:00:00 2001
From: Jorge Canizales <jcanizales@google.com>
Date: Fri, 17 Jul 2015 12:19:13 -0700
Subject: [PATCH] Remove GRXWriter wrappers that are now unnecessary

With GRXWriter a subclass of all writers, we can map the requestsWriter directly
without a dumb wrapper, and return GRXImmediateWriter objects where GRXWriter is
expected.
---
 src/objective-c/ProtoRPC/ProtoRPC.m             | 12 +++++-------
 src/objective-c/RxLibrary/GRXWriter+Immediate.m | 12 ++++++------
 2 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/src/objective-c/ProtoRPC/ProtoRPC.m b/src/objective-c/ProtoRPC/ProtoRPC.m
index 067c359765..889d71a308 100644
--- a/src/objective-c/ProtoRPC/ProtoRPC.m
+++ b/src/objective-c/ProtoRPC/ProtoRPC.m
@@ -35,7 +35,6 @@
 
 #import <GPBProtocolBuffers.h>
 #import <RxLibrary/GRXWriteable.h>
-#import <RxLibrary/GRXForwardingWriter.h>
 #import <RxLibrary/GRXWriter+Transformations.h>
 
 @implementation ProtoRPC {
@@ -65,12 +64,11 @@
                 format:@"A protobuf class to parse the responses must be provided."];
   }
   // A writer that serializes the proto messages to send.
-  id<GRXWriter> bytesWriter =
-      [[[GRXForwardingWriter alloc] initWithWriter:requestsWriter] map:^id(GPBMessage *proto) {
-        // TODO(jcanizales): Fail with an understandable error message if the requestsWriter isn't
-        // sending GPBMessages.
-        return [proto data];
-      }];
+  GRXWriter *bytesWriter = [requestsWriter map:^id(GPBMessage *proto) {
+    // TODO(jcanizales): Fail with an understandable error message if the requestsWriter isn't
+    // sending GPBMessages.
+    return [proto data];
+  }];
   if ((self = [super initWithHost:host path:method.HTTPPath requestsWriter:bytesWriter])) {
     // A writeable that parses the proto messages received.
     _responseWriteable = [[GRXWriteable alloc] initWithValueHandler:^(NSData *value) {
diff --git a/src/objective-c/RxLibrary/GRXWriter+Immediate.m b/src/objective-c/RxLibrary/GRXWriter+Immediate.m
index 39c54f86ec..1d55eb3529 100644
--- a/src/objective-c/RxLibrary/GRXWriter+Immediate.m
+++ b/src/objective-c/RxLibrary/GRXWriter+Immediate.m
@@ -38,27 +38,27 @@
 @implementation GRXWriter (Immediate)
 
 + (instancetype)writerWithEnumerator:(NSEnumerator *)enumerator {
-  return [[self alloc] initWithWriter:[GRXImmediateWriter writerWithEnumerator:enumerator]];
+  return [GRXImmediateWriter writerWithEnumerator:enumerator];
 }
 
 + (instancetype)writerWithValueSupplier:(id (^)())block {
-  return [[self alloc] initWithWriter:[GRXImmediateWriter writerWithValueSupplier:block]];
+  return [GRXImmediateWriter writerWithValueSupplier:block];
 }
 
 + (instancetype)writerWithContainer:(id<NSFastEnumeration>)container {
-  return [[self alloc] initWithWriter:[GRXImmediateWriter writerWithContainer:container]];
+  return [GRXImmediateWriter writerWithContainer:container];
 }
 
 + (instancetype)writerWithValue:(id)value {
-  return [[self alloc] initWithWriter:[GRXImmediateWriter writerWithValue:value]];
+  return [GRXImmediateWriter writerWithValue:value];
 }
 
 + (instancetype)writerWithError:(NSError *)error {
-  return [[self alloc] initWithWriter:[GRXImmediateWriter writerWithError:error]];
+  return [GRXImmediateWriter writerWithError:error];
 }
 
 + (instancetype)emptyWriter {
-  return [[self alloc] initWithWriter:[GRXImmediateWriter emptyWriter]];
+  return [GRXImmediateWriter emptyWriter];
 }
 
 @end
-- 
GitLab