Skip to content
This repository was archived by the owner on Jul 8, 2022. It is now read-only.

Add a map in MultiAttribute object to improve performances (#424)#430

Merged
bourtemb merged 2 commits intotango-controls:tango-9-ltsfrom
bourtemb:cppTango-424-map-with-index-tango-9-lts
Feb 19, 2018
Merged

Add a map in MultiAttribute object to improve performances (#424)#430
bourtemb merged 2 commits intotango-controls:tango-9-ltsfrom
bourtemb:cppTango-424-map-with-index-tango-9-lts

Conversation

@bourtemb
Copy link
Copy Markdown
Member

This solution is using an std::map.
Using an unordered_map if the compiler supports it could slightly improve the performances even more.
The gain is already big using an std::map.

Copy link
Copy Markdown
Member

@Ingvord Ingvord left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some improvements can be applied IMHO

// - att : The newly configured attribute
//
//-------------------------------------------------------------------------------------------------------------------
void MultiAttribute::add_attr(Attribute *att)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be overloaded with add_attr(Attribute *att, size_t index) and used to prevent code duplications above.

Copy link
Copy Markdown
Member

@Ingvord Ingvord Feb 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After a little bit more thinking I think it would be better to split this method into two:

size_t add_attr(Attribute), where size_t is an index of the newly added attribute, may be passed via overloaded method aka size_t add_attr(Attribute, index)

void put_attr_into_map(Attribute, index)

And finally aggregate these two in a third one:

size_t ndx = add_attr(attr);
put_attr_into_map(attr, ndx)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added put_attribute_in_map() method to reduce code duplication...
add_attr() method is used in some other parts of the code and already existed before this PR so I think we should stick with the same interface for this method.
I could rename put_attribute_in_map in put_attr_into_map if you prefer...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bourtemb that is just fine keep it as it is now!

ite = attr_list.end() - 2;

attr_list.insert(ite,new FwdAttribute(prop_list,*new_attr,dev_name,index));
Attribute * new_fwd_attr = new FwdAttribute(prop_list,*new_attr,dev_name,index);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to me as a code duplication. Must be extracted into a dedicated method overloaded from add_attr, see below

else
{
attr_list.insert(ite,new Attribute(prop_list,attr,dev_name,index));
Attribute * new_attr = new Attribute(prop_list,attr,dev_name,index);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to me as a code duplication. Must be extracted into a dedicated method overloaded from add_attr, see below

else
{
attr_list.insert(ite,new WAttribute(prop_list,attr,dev_name,index));
Attribute * new_attr = new WAttribute(prop_list,attr,dev_name,index);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to me as a code duplication. Must be extracted into a dedicated method overloaded from add_attr, see below

@bourtemb bourtemb merged commit e46e769 into tango-controls:tango-9-lts Feb 19, 2018
bourtemb added a commit to bourtemb/cppTango that referenced this pull request May 25, 2018
…vector.

Indexes are now correctly updated taking this into account (tango-controls#458).
This should fix a bug introduced in tango-controls#430 which was impacting servers using dynamic attributes.
bourtemb added a commit to bourtemb/cppTango that referenced this pull request May 29, 2018
…vector.

Indexes are now correctly updated taking this into account (tango-controls#458).
This should fix a bug introduced in tango-controls#430 which was impacting servers using dynamic attributes.
bourtemb added a commit that referenced this pull request May 30, 2018
… map (#459)

State and Status attributes should always be at the end of attributes list vector.
Indexes are now correctly updated taking this into account (#458).
This should fix a bug introduced in #430 which was impacting servers using dynamic attributes.
bourtemb added a commit to bourtemb/cppTango that referenced this pull request Jul 17, 2018
… map (tango-controls#459)

State and Status attributes should always be at the end of attributes list vector.
Indexes are now correctly updated taking this into account (tango-controls#458).
This should fix a bug introduced in tango-controls#430 which was impacting servers using dynamic attributes.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants