Skip to content
Snippets Groups Projects
Commit 19763bb6 authored by Daniel Salzman's avatar Daniel Salzman
Browse files

node: make some function inline static

parent e3094e3a
No related branches found
No related tags found
1 merge request!988Implementation of COW trie for zone updates
......@@ -16,7 +16,6 @@
#include "knot/zone/node.h"
#include "libknot/libknot.h"
#include "contrib/macros.h"
void additional_clear(additional_t *additional)
{
......@@ -131,7 +130,10 @@ zone_node_t *node_new(const knot_dname_t *owner, bool binode, bool second, knot_
return ret;
}
zone_node_t *binode_counterpart(zone_node_t *node)
/*!
* \brief Return the other part of a bi-node.
*/
static zone_node_t *binode_counterpart(zone_node_t *node)
{
zone_node_t *counterpart = NULL;
......@@ -191,14 +193,6 @@ int binode_prepare_change(zone_node_t *node, knot_mm_t *mm)
return KNOT_EOK;
}
zone_node_t *binode_node(zone_node_t *node, bool second)
{
if (unlikely(node == NULL || !(node->flags & NODE_FLAGS_BINODE))) {
return node;
}
return node + (second - (int)((node->flags & NODE_FLAGS_SECOND) >> 9));
}
bool binode_rdata_shared(zone_node_t *node, uint16_t type)
{
if (node == NULL || !(node->flags & NODE_FLAGS_BINODE)) {
......@@ -367,23 +361,6 @@ void node_set_parent(zone_node_t *node, zone_node_t *parent)
}
}
zone_node_t *node_parent(const zone_node_t *node)
{
return binode_node(node->parent, (node->flags & NODE_FLAGS_SECOND));
}
zone_node_t *node_prev(const zone_node_t *node)
{
return binode_node(node->prev, (node->flags & NODE_FLAGS_SECOND));
}
const zone_node_t *glue_node(const glue_t *glue, const zone_node_t *another_zone_node)
{
UNUSED(another_zone_node);
return binode_node((zone_node_t *)glue->node,
(another_zone_node->flags & NODE_FLAGS_SECOND));
}
bool node_rrtype_is_signed(const zone_node_t *node, uint16_t type)
{
if (node == NULL) {
......
......@@ -16,6 +16,7 @@
#pragma once
#include "contrib/macros.h"
#include "contrib/mempattern.h"
#include "libknot/descriptor.h"
#include "libknot/dname.h"
......@@ -119,11 +120,6 @@ bool additional_equal(additional_t *a, additional_t *b);
*/
zone_node_t *node_new(const knot_dname_t *owner, bool binode, bool second, knot_mm_t *mm);
/*!
* \brief Return the other part of a bi-node.
*/
zone_node_t *binode_counterpart(zone_node_t *node);
/*!
* \brief Synchronize contents of both binode's nodes.
*
......@@ -146,7 +142,13 @@ int binode_prepare_change(zone_node_t *node, knot_mm_t *mm);
*
* \return Pointer to correct node.
*/
zone_node_t *binode_node(zone_node_t *node, bool second);
inline static zone_node_t *binode_node(zone_node_t *node, bool second)
{
if (unlikely(node == NULL || !(node->flags & NODE_FLAGS_BINODE))) {
return node;
}
return node + (second - (int)((node->flags & NODE_FLAGS_SECOND) >> 9));
}
/*!
* \brief Return true if the rdataset of specified type is shared (shallow-copied) among both parts of bi-node.
......@@ -230,12 +232,18 @@ void node_set_parent(zone_node_t *node, zone_node_t *parent);
/*!
* \brief Returns parent node (fixing bi-node issue) of given node.
*/
zone_node_t *node_parent(const zone_node_t *node);
inline static zone_node_t *node_parent(const zone_node_t *node)
{
return binode_node(node->parent, (node->flags & NODE_FLAGS_SECOND));
}
/*!
* \brief Returns previous (lexicographically in same zone tree) node (fixing bi-node issue) of given node.
*/
zone_node_t *node_prev(const zone_node_t *node);
inline static zone_node_t *node_prev(const zone_node_t *node)
{
return binode_node(node->prev, (node->flags & NODE_FLAGS_SECOND));
}
/*!
* \brief Return node referenced by a glue.
......@@ -245,7 +253,11 @@ zone_node_t *node_prev(const zone_node_t *node);
*
* \return Glue node.
*/
const zone_node_t *glue_node(const glue_t *glue, const zone_node_t *another_zone_node);
inline static const zone_node_t *glue_node(const glue_t *glue, const zone_node_t *another_zone_node)
{
return binode_node((zone_node_t *)glue->node,
(another_zone_node->flags & NODE_FLAGS_SECOND));
}
/*!
* \brief Checks whether node contains any RRSIG for given type.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment