Field de-duplication

add a global cache of Field instances to
allow O(0) comparison of types.
This commit is contained in:
Michael Davidsaver
2018-02-06 13:12:39 -08:00
parent a1c0e432ee
commit 0406a2f614
5 changed files with 167 additions and 112 deletions

View File

@@ -24,6 +24,8 @@
#include <pv/noDefaultMethods.h>
#include <pv/byteBuffer.h>
#include <pv/convert.h>
#include <pv/pvUnitTest.h>
#include <pv/current_function.h>
#include <pv/standardField.h>
@@ -629,6 +631,8 @@ void testStructureId() {
void serializationFieldTest(FieldConstPtr const & field)
{
testShow()<<CURRENT_FUNCTION<<"\n"<<field;
buffer->clear();
// serialize
@@ -639,7 +643,7 @@ void serializationFieldTest(FieldConstPtr const & field)
FieldConstPtr deserializedField = getFieldCreate()->deserialize(buffer, control);
// must equal
testShow()<<" after "<<(void*)field.get()<<" == "<<(void*)deserializedField.get();
testOk1(*field == *deserializedField);
}

View File

@@ -324,8 +324,8 @@ void test_extendStructure()
<<"amended: "<<amended
<<"expected: "<<expected;
testNotEqual(static_cast<const void*>(amended.get()),
static_cast<const void*>(expected.get()));
testEqual(static_cast<const void*>(amended.get()),
static_cast<const void*>(expected.get()));
testEqual(*amended, *expected);
testThrows(std::runtime_error,