瀏覽代碼

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 年之前
父節點
當前提交
d4a58a3181
共有 1 個文件被更改,包括 1 次插入0 次删除
  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] = []