Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Wireshark-dev: Re: [Wireshark-dev] ew function(s) proto_tree_new_item_get_val_..()

From: Jeff Morriss <jeff.morriss.ws@xxxxxxxxx>
Date: Thu, 13 Jan 2011 12:27:29 -0500
Anders Broman wrote:
Jaap Keuter skrev 2011-01-12 22:42:
Hi,

Oke, so now the reason is CPU cycles. Show the profiling; is it *really* worth it? There was a recent thread around tvb_get_ptr() as being far more efficient. Profiling disproved that.

Actually I did eventually find Martin's code to be faster than mine, it just took a better method (tshark instead of GUI) and a much bigger capture file (or testing on a CPU where memcpy()s are expensive).

? speed was the whole point. Unfortunately I'm not sure how to profile it. But if no one thinks it's
a good idea I'll drop it.

Well, I can also see a point because it reduces the lines of code a dissector writer needs in these cases. (I too have found it mildly annoying when I need to add_item() then tvb_get...() the same thing because I need to test its value.)

In Lua such a function would be great because one function could return any type of FT_XXX, but... I'm not sure it would be worth another 15-20(? maybe I'm exaggerating?) proto_tree_add_*() functions: there's already too many...

I stand by keeping your API orthogonal and clean.
What's orthogonal?

From: http://en.wikipedia.org/wiki/Orthogonal#Computer_science

Orthogonality is a system design property facilitating feasibility and compactness of complex designs.