Skip to content

Commit

Permalink
Re #1791 remove redundant code and decrease code duplication.
Browse files Browse the repository at this point in the history
  • Loading branch information
abuts committed Jan 23, 2025
1 parent 912e826 commit 5c8717d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
gid = obj.idx_(1:obj.max_obj_idx_);
end
end
end
end

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
'not correct base class; object was not added');
end

% call find_in_container to get ix and hash
% call find_in_container to get ix and hash
[ix,hash,obj] = self.find_in_container(obj);


Expand All @@ -32,7 +32,7 @@
% store the object in the stored objects
% take the index of the last stored object as the object index
if isempty(ix) % means obj not in container and should be added
self.stored_hashes_ = [self.stored_hashes_(:);hash]';
self.stored_hashes_ = [self.stored_hashes_(:);hash]';
self.unique_objects_ = [self.unique_objects_(:); {obj}]';

ix = numel(self.unique_objects_);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
end
end
storage = unique_obj_store.instance().get_objects(self.baseclass);
self.idx_ = zeros(1,val.n_objects);
for i=1:val.n_objects
[storage,gidx] = storage.add(val(i));
self.idx_(i) = gidx;
end
[storage,gidx] = storage.add(val);
self.idx_ = gidx;
% this code is part of more general method, which sends changes in storage
% to global store. No need to do it here. set_objecs will be done later.
11 changes: 6 additions & 5 deletions herbert_core/utilities/classes/ObjContainersBase.m
Original file line number Diff line number Diff line change
Expand Up @@ -277,19 +277,20 @@ function list(self,field)
[self,nuix] = self.add_single(obj);
end % add()
%
function obj = get(self,nuix)
function obj = get(self,nguix)
% given the non-unique global index nuix that you know about
% for your object (it was returned when you added it to the
% container with add or replace) get the unique object
% associated with this index.
%
% Input:
% - nuix : non-unique index that has been stored somewhere for
% this object
% - nguix : non-unique index that has been stored somewhere for
% this object and identifies the location of the
% object in unique_obj_store.container.
% Output:
% - obj : the unique object store for this index
% - obj : the unique object located at this index
%
obj = self.get_unique_objects(nuix);
obj = self.get_unique_objects(nguix);
end
end
% Setter/getters for common interface with class-specific
Expand Down

0 comments on commit 5c8717d

Please sign in to comment.