epics-base / pvDataCPP

pvDataCPP is an EPICS V4 C++ module
https://epics-base.github.io/pvDataCPP/
Other
6 stars 16 forks source link

Field instance de-duplication #55

Closed mdavidsaver closed 6 years ago

mdavidsaver commented 6 years ago

In an effort to make Field (aka type) comparison cheap, so that it can be done more often, use a global hash table to prevent duplicate instances of Field (and associated sub-classes). operator== for Field becomes simple pointer comparison (the existing comparison is renamed to epics::pvData::compare()).

This does make Field creation more expensive, but this is not something which a well behaved program should do frequently (after startup).

Hashing is done with the simple (though inefficient) expedient of applying epicsStrHash() to the output of operator<<.