Browse Source

Avoid a CoW in the client read state (#1533)

Motivation:

In some Swift versions the reader is CoW'd when appending in one of the
client state machines substates.

Modifications:

- Temporarily switch state before appending to the reader

Result:

Fewer CoWs
George Barnett 3 years ago
parent
commit
d4a58a3181
1 changed files with 1 additions and 0 deletions
  1. 1 0
      Sources/GRPC/ReadWriteStates.swift

+ 1 - 0
Sources/GRPC/ReadWriteStates.swift

@@ -150,6 +150,7 @@ enum ReadState {
       return .failure(.cardinalityViolation)
 
     case .reading(let readArity, var reader):
+      self = .notReading // Avoid CoWs
       reader.append(buffer: &buffer)
       var messages: [ByteBuffer] = []