diff options
| author | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2015-04-16 01:40:22 +0200 | 
|---|---|---|
| committer | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2016-04-25 22:26:12 +0200 | 
| commit | 5f32cfb7d244106e77d9ec5e09161af1433ad5e9 (patch) | |
| tree | cc4db2c0719ca2e525b155a6b7513eefc7c50c8d /src | |
| parent | 7dc48b549b7789a38f0b066528de880a06525592 (diff) | |
Prevent inserting the same Node multiple times into the nodesWithoutId vector using a set. Keep the vector in order to generate the ids in a deterministic order.
Diffstat (limited to 'src')
| -rw-r--r-- | src/transformations/uniqueid/UniqueIdTransformation.cpp | 10 | 
1 files changed, 9 insertions, 1 deletions
diff --git a/src/transformations/uniqueid/UniqueIdTransformation.cpp b/src/transformations/uniqueid/UniqueIdTransformation.cpp index 028c1ef..6065e9d 100644 --- a/src/transformations/uniqueid/UniqueIdTransformation.cpp +++ b/src/transformations/uniqueid/UniqueIdTransformation.cpp @@ -43,6 +43,11 @@ private:  	ManagedVector<Node> nodesWithoutId;  	/** +	 * Set preventing multi-insertion into the nodesWithoutId vector. +	 */ +	std::unordered_set<Managed *> nodesWithoutIdSet; + +	/**  	 * Traverse the document tree -- find all elements with primitive content.  	 */  	std::queue<Rooted<StructuredEntity>> queue; @@ -80,7 +85,10 @@ void UniqueIdTransformationImpl::processVariant(const Variant &var)  	} else if (var.isObject()) {  		Rooted<Managed> obj = var.asObject();  		if (!obj->hasDataKey("id") && obj->isa(&RttiTypes::Node)) { -			nodesWithoutId.push_back(obj.cast<Node>()); +			if (nodesWithoutIdSet.count(obj.get()) == 0) { +				nodesWithoutId.push_back(obj.cast<Node>()); +				nodesWithoutIdSet.insert(obj.get()); +			}  		}  	}  }  | 
