浏览代码

Add LSUP_graph_copy() shortcut; optimize LSUP_term_equals.

scossu 1 周之前
父节点
当前提交
38171d61b5
共有 2 个文件被更改,包括 18 次插入2 次删除
  1. 17 1
      include/graph.h
  2. 1 1
      include/term.h

+ 17 - 1
include/graph.h

@@ -91,11 +91,27 @@ LSUP_graph_copy_contents_txn (
         const LSUP_Term *s, const LSUP_Term *p, const LSUP_Term *o);
 
 
-/// Non-transactional version of #LSUP_graph_copy_contents_txn.
+/// Non-transactional version of #LSUP_graph_copy_contents_txn().
 #define LSUP_graph_copy_contents(...) \
     LSUP_graph_copy_contents_txn (NULL, __VA_ARGS__)
 
 
+/* @brief Copy all triples from a graph.
+ *
+ * This is a shortcut for #LSUP_graph_copy_contents_txn(). If you need to
+ * specify a transaction handle and/or a filter for the copy, use that.
+ *
+ * @param src[in] Source graph.
+ *
+ * @param dest[in] Destination graph.
+ *
+ * @return LSUP_OK on success; LSUP_NOACTION if no triples were copied; <0
+ *  if an error occurred.
+ */
+#define LSUP_graph_copy(src, dest) \
+    LSUP_graph_copy_contents_txn (NULL, src, dest, NULL, NULL, NULL)
+
+
 /** Perform a boolean operation between two graphs.
  *
  * This method populates an initialized graph with the result of the operation

+ 1 - 1
include/term.h

@@ -320,7 +320,7 @@ LSUP_term_hash (const LSUP_Term *term);
  * semantically equivalent.
  */
 inline bool LSUP_term_equals (const LSUP_Term *term1, const LSUP_Term *term2)
-{ return LSUP_term_hash (term1) == LSUP_term_hash (term2); }
+{ return term1 == term2 || LSUP_term_hash (term1) == LSUP_term_hash (term2); }
 
 
 void