return tree;
}
+/* finds the largest version in the array, that is <= the query version */
+static inline GTreeRootVersion *
+g_tree_root_find_version (GTree *tree,
+ guint version)
+{
+ GTreeRootVersion *const v = tree->roots;
+ const guint nv = tree->nroots;
+ GTreeRootVersion *l, *r;
+
+ /* note: we never search for a version smaller than the smallest
+ version in the array */
+
+ if (v[0].version <= version)
+ return v;
+
+ l = v+1;
+ r = v+(nv-1);
+ while (l <= r) /* binary search */
+ {
+ GTreeRootVersion *const m = l + (r - l) / 2;
+ if (version == m->version)
+ return m;
+ else if (version < m->version)
+ r = m-1;
+ else
+ l = m+1;
+ }
+ g_assert (r->version < version);
+ g_assert (l->version > version);
+ return r;
+}
+
+static inline GTreeNodeVersion *
+g_tree_node_find_version(GTreeNode *node,
+ guint version)
+{
+ GTreeNodeVersion *const v = node->v;
+ const guint nv = node->nv;
+ GTreeNodeVersion *n;
+
+ /* note: we never search for a version smaller than the smallest
+ version in the array */
+
+ if (v[0].version <= version)
+ return v;
+
+ /* there are at most MAX_IN_DEGREE+1 things to look through, which is small,
+ so just scan through them from largest version to smallest */
+ for (n = v+(nv-1); n != v; --n)
+ if (n->version <= version)
+ break;
+ g_assert (n != v);
+ return n;
+}
+
static inline GTreeNode *
g_tree_first_node (GTree *tree)
{
}
}
-/* finds the largest version in the array, that is <= the query version */
-static inline GTreeRootVersion *
-g_tree_root_find_version (GTree *tree,
- guint version)
-{
- GTreeRootVersion *const v = tree->roots;
- const guint nv = tree->nroots;
- GTreeRootVersion *l, *r;
-
- /* note: we never search for a version smaller than the smallest
- version in the array */
-
- if (v[0].version <= version)
- return v;
-
- l = v+1;
- r = v+(nv-1);
- while (l <= r) /* binary search */
- {
- GTreeRootVersion *const m = l + (r - l) / 2;
- if (version == m->version)
- return m;
- else if (version < m->version)
- r = m-1;
- else
- l = m+1;
- }
- g_assert (r->version < version);
- g_assert (l->version > version);
- return r;
-}
-
-static inline GTreeNodeVersion *
-g_tree_node_find_version(GTreeNode *node,
- guint version)
-{
- GTreeNodeVersion *const v = node->v;
- const guint nv = node->nv;
- GTreeNodeVersion *n;
-
- /* note: we never search for a version smaller than the smallest
- version in the array */
-
- if (v[0].version <= version)
- return v;
-
- /* there are at most MAX_IN_DEGREE+1 things to look through, which is small,
- so just scan through them from largest version to smallest */
- for (n = v+(nv-1); n != v; --n)
- if (n->version <= version)
- break;
- g_assert (n != v);
- return n;
-}
-
/**
* g_tree_insert:
* @tree: a #GTree.