Skip to content
  • Nathan Harris's avatar
    59 -- Use `RESPValueConvertible` as Generic Constraint · fa227b0e
    Nathan Harris authored
    Motivation:
    
    Johannes continues to provide great insight, and correctly pointed out that `RESPValueConvertible` was being used as an "existential" in all cases.
    
    This can cause unexpected type-erasure and introduce unnecessary cost overhead with dynamic dispatch when in most cases we know the exact value we want for `RESPValue` to execute commands.
    
    Modifications:
    
    - Add new extensions to `Array where Element == RESPValue` for appending and adding elements into them
    - Change `RedisClient.send(command:with:)` to require `[RESPValue]` instead of `[RESPValueConvertible]` as the `with` argument type
    - Change all instances of `RESPValueConvertible` being an "existential" type for method arguments to instead be a generic constraint
    
    Result:
    
    The library should be safeguarded from a class of bugs, with the use of `send` being a bit more straight forward, with some new convenience methods for `[RESPValue]` types.
    fa227b0e