浏览代码

Performance improvement for allIncomingAssociationInstances

Yentl Van Tendeloo 8 年之前
父节点
当前提交
d51112ba0e
共有 1 个文件被更改,包括 20 次插入0 次删除
  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