Explorar o código

Performance improvement for allIncomingAssociationInstances

Yentl Van Tendeloo %!s(int64=8) %!d(string=hai) anos
pai
achega
d51112ba0e
Modificáronse 1 ficheiros con 20 adicións e 0 borrados
  1. 20 0
      bootstrap/object_operations.alc

+ 20 - 0
bootstrap/object_operations.alc

@@ -84,6 +84,26 @@ Element function allOutgoingAssociationInstances(model : Element, source_name :
 	return result!
 
 Element function allIncomingAssociationInstances(model : Element, target_name : String, assoc_name : String):
+	// Read out all outgoing edges of the model and select those that are typed by the specified association
+	Element result
+	Element source
+	String option
+	Integer all_out
+	Integer i
+
+	result = create_node()
+	source = model["model"][target_name]
+	all_out = read_nr_in(source)
+	i = 0
+	while (i < all_out):
+		option = reverseKeyLookup(model["model"], read_in(source, i))
+		if (is_nominal_instance(model, option, assoc_name)):
+			set_add(result, option)
+		i = i + 1
+
+	return result!
+
+Element function allIncomingAssociationInstances_slow(model : Element, target_name : String, assoc_name : String):
 	// Read out all outgoing edges of the model and select those that are typed by the specified association
 	Element assocs
 	String assoc