Don't clone data by default. User can clone only when relevant.

master
Philippe PITTOLI 2024-05-07 13:05:01 +02:00
parent 345390f4db
commit bb6d9a26f7
1 changed files with 5 additions and 1 deletions

View File

@ -44,8 +44,12 @@ class DODB::CachedDataBase(V) < DODB::Storage(V)
# FIXME: rescues any error the same way.
return nil
end
# WARNING: data isn't cloned.
# You have to do it yourself in case you modify any value,
# otherwise you may encounter problems (at least with indexes).
def [](key : Int32) : V
@data[key].clone rescue raise MissingEntry.new(key)
@data[key] rescue raise MissingEntry.new(key)
end
def []=(index : Int32, value : V)