icerpc / icerpc-csharp

A C# RPC framework built for QUIC, with bidirectional streaming, first-class async/await, and Protobuf support.
https://docs.icerpc.dev
Apache License 2.0
101 stars 13 forks source link

Remove redundant cast in 'decode_func_body' for collections. #3913

Closed InsertCreativityHere closed 7 months ago

InsertCreativityHere commented 7 months ago

After investigating the way we cast sequences and dictionaries, I noticed we're accidentally generating a double cast for optional nested sequences and dictionaries. One that we always generate for lambdas, and another we always generate for sequences and dictionaries. This PR removes removes the double-cast:

                 size => new global::System.Collections.Generic.Dictionary<string, global::System.Collections.Generic.IDictionary<string, bool>?>(size),
                 (ref SliceDecoder decoder) => decoder.DecodeString(),
-                (ref SliceDecoder decoder) => (global::System.Collections.Generic.Dictionary<string, bool>?)decoder.DecodeDictionary(
+                (ref SliceDecoder decoder) => decoder.DecodeDictionary(
                     size => new global::System.Collections.Generic.Dictionary<string, bool>(size),
                     (ref SliceDecoder decoder) => decoder.DecodeString(),