Skip to content

Commit

Permalink
optimized TRestStorageInMemory
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnaud Bouchez committed Oct 18, 2022
1 parent bf2f866 commit 00942dc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/mormot.commit.inc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
'2.0.4215'
'2.0.4216'
8 changes: 4 additions & 4 deletions src/orm/mormot.orm.storage.pas
Original file line number Diff line number Diff line change
Expand Up @@ -2416,7 +2416,7 @@ function TRestStorageInMemory.UniqueFieldsUpdateOK(aRec: TOrm;
for f := 0 to length(fUnique) - 1 do
with fUnique[f] do
if (aFields = nil) or
(byte(PropInfo.PropertyIndex) in aFields^) then
FieldBitGet(aFields^, PropInfo.PropertyIndex) then
begin
ndx := Find(aRec);
if (ndx >= 0) and
Expand Down Expand Up @@ -2727,7 +2727,7 @@ function TRestStorageInMemory.FindWhereEqual(WhereField: integer;
// nothing to search (e.g. oftUnknown or oftMany)
exit;
// use fUnique[] hash array for O(1) search if available
if WhereField in fStoredClassRecordProps.IsUniqueFieldsBits then
if FieldBitGet(fStoredClassRecordProps.IsUniqueFieldsBits, WhereField) then
begin
if FoundOffset <= 0 then
begin
Expand Down Expand Up @@ -3808,7 +3808,7 @@ function TRestStorageInMemory.EngineUpdateFieldIncrement(
P := fStoredClassProps.Prop[FieldName];
if P = nil then
exit;
if P.PropertyIndex in fStoredClassRecordProps.IsUniqueFieldsBits then
if FieldBitGet(fStoredClassRecordProps.IsUniqueFieldsBits, P.PropertyIndex) then
begin
InternalLog('EngineUpdateFieldIncrement(%) on UNIQUE %.%',
[ID, fStoredClass, P.Name], sllDB);
Expand Down Expand Up @@ -3878,7 +3878,7 @@ function TRestStorageInMemory.EngineUpdateField(TableModelIndex: integer;
P := fStoredClassRecordProps.Fields.ByRawUtf8Name(SetFieldName);
if P = nil then
exit; // don't allow setting ID field, which is Read Only
if P.PropertyIndex in fStoredClassRecordProps.IsUniqueFieldsBits then
if FieldBitGet(fStoredClassRecordProps.IsUniqueFieldsBits, P.PropertyIndex) then
begin
InternalLog('EngineUpdateField on UNIQUE %.%', [fStoredClass, P.Name], sllDB);
exit; { TODO : allow update UNIQUE field? }
Expand Down

0 comments on commit 00942dc

Please sign in to comment.