Skip to content

Commit

Permalink
reduce memory overhead on list
Browse files Browse the repository at this point in the history
  • Loading branch information
pchalamet committed Dec 25, 2024
1 parent 40fafda commit 7c5af3d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
8 changes: 4 additions & 4 deletions FSharp.MongoDB.Driver/Serializers/List.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ open MongoDB.Bson.Serialization
type internal ListSerializer<'T>() =
inherit SerializerBase<List<'T>>()

let contentSerializer = BsonSerializer.LookupSerializer(typeof<'T[]>)
let contentSerializer = BsonSerializer.LookupSerializer(typeof<System.Collections.Generic.IEnumerable<'T>>)

override _.Serialize(context, _, value) =
let list = value |> List.toArray
let list = value
contentSerializer.Serialize(context, list)

override _.Deserialize(context, args) =
let list = contentSerializer.Deserialize(context, args) :?>'T[]
list |> List.ofArray
let list = contentSerializer.Deserialize(context, args) :?> System.Collections.Generic.IEnumerable<'T>
list |> List.ofSeq
1 change: 0 additions & 1 deletion FSharp.MongoDB.Driver/Serializers/Map.fs
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@ type internal MapSerializer<'K, 'V when 'K : comparison>() =
override _.Deserialize(context, args) =
let dict = contentSerializer.Deserialize(context, args) :?> System.Collections.Generic.IDictionary<'K, 'V>
dict |> Seq.map (|KeyValue|) |> Map.ofSeq

0 comments on commit 7c5af3d

Please sign in to comment.