aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorRonnie Sahlberg <ronnie_sahlberg@ozemail.com.au>2003-12-03 09:50:40 +0000
committerRonnie Sahlberg <ronnie_sahlberg@ozemail.com.au>2003-12-03 09:50:40 +0000
commit5ff0237060f1b93f5efe8e4041bbde2a2f674cbe (patch)
tree7eb2780a520c46705e1065d50ef30e9c7d58eed4 /epan
parentdcd98ae8d334081d0b4e0f4c6902ac128dfeb000 (diff)
performance update
replace tvb_raw_offset() which is essentially a simple assignment and which is called a lot with a macro. this makes my tethereal testcase 2-3% faster. svn path=/trunk/; revision=9152
Diffstat (limited to 'epan')
-rw-r--r--epan/proto.c8
-rw-r--r--epan/tvbuff.c13
-rw-r--r--epan/tvbuff.h7
3 files changed, 10 insertions, 18 deletions
diff --git a/epan/proto.c b/epan/proto.c
index 9d215e8ccf..52fb49f5c7 100644
--- a/epan/proto.c
+++ b/epan/proto.c
@@ -1,7 +1,7 @@
/* proto.c
* Routines for protocol tree
*
- * $Id: proto.c,v 1.122 2003/12/03 09:28:22 guy Exp $
+ * $Id: proto.c,v 1.123 2003/12/03 09:50:40 sahlberg Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -1884,9 +1884,7 @@ alloc_field_info(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
fi->hfinfo = hfinfo;
fi->start = start;
- if (tvb) {
- fi->start += tvb_raw_offset(tvb);
- }
+ fi->start+=(tvb)?TVB_RAW_OFFSET(tvb):0;
fi->length = *length;
fi->tree_type = -1;
fi->visible = PTREE_DATA(tree)->visible;
@@ -2001,7 +1999,7 @@ proto_item_set_end(proto_item *pi, tvbuff_t *tvb, gint end)
if (pi == NULL)
return;
fi = PITEM_FINFO(pi);
- end += tvb_raw_offset(tvb);
+ end += TVB_RAW_OFFSET(tvb);
fi->length = end - fi->start;
}
diff --git a/epan/tvbuff.c b/epan/tvbuff.c
index c3b8a69a2d..b1bcd31c14 100644
--- a/epan/tvbuff.c
+++ b/epan/tvbuff.c
@@ -9,7 +9,7 @@
* the data of a backing tvbuff, or can be a composite of
* other tvbuffs.
*
- * $Id: tvbuff.c,v 1.52 2003/12/02 10:23:18 sahlberg Exp $
+ * $Id: tvbuff.c,v 1.53 2003/12/03 09:50:40 sahlberg Exp $
*
* Copyright (c) 2000 by Gilbert Ramirez <gram@alumni.rice.edu>
*
@@ -717,7 +717,7 @@ first_real_data_ptr(tvbuff_t *tvb)
return NULL;
}
-static int
+int
offset_from_real_beginning(tvbuff_t *tvb, int counter)
{
tvbuff_t *member;
@@ -737,15 +737,6 @@ offset_from_real_beginning(tvbuff_t *tvb, int counter)
return 0;
}
-gint
-tvb_raw_offset(tvbuff_t *tvb)
-{
- if (tvb->raw_offset == -1) {
- tvb->raw_offset = offset_from_real_beginning(tvb, 0);
- }
- return tvb->raw_offset;
-}
-
static guint8*
composite_ensure_contiguous_no_exception(tvbuff_t *tvb, guint abs_offset,
guint abs_length)
diff --git a/epan/tvbuff.h b/epan/tvbuff.h
index 2758f136c8..aa5339510a 100644
--- a/epan/tvbuff.h
+++ b/epan/tvbuff.h
@@ -9,7 +9,7 @@
* the data of a backing tvbuff, or can be a composite of
* other tvbuffs.
*
- * $Id: tvbuff.h,v 1.35 2003/12/02 10:23:18 sahlberg Exp $
+ * $Id: tvbuff.h,v 1.36 2003/12/03 09:50:40 sahlberg Exp $
*
* Copyright (c) 2000 by Gilbert Ramirez <gram@alumni.rice.edu>
*
@@ -284,8 +284,11 @@ extern gint tvb_reported_length_remaining(tvbuff_t *tvb, gint offset);
Also adjusts the data length. */
extern void tvb_set_reported_length(tvbuff_t*, guint);
+extern int offset_from_real_beginning(tvbuff_t *tvb, int counter);
+
/* Returns the offset from the first byte of real data. */
-extern gint tvb_raw_offset(tvbuff_t*);
+#define TVB_RAW_OFFSET(tvb) \
+ ((tvb->raw_offset==-1)?(tvb->raw_offset = offset_from_real_beginning(tvb, 0)):tvb->raw_offset)
/************** START OF ACCESSORS ****************/
/* All accessors will throw an exception if appropriate */