Ethereal-dev: Re: [Ethereal-dev] README.developer - if (tree)

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Guy Harris <guy@xxxxxxxxxxxx>
Date: Tue, 16 Dec 2003 13:01:32 -0800

On Dec 16, 2003, at 12:51 PM, Biot Olivier wrote:

If I remember correctly, one does not need to write an
if (tree) { } around all proto_XXX_add_YYY() as this is
already dealt with in the proto_XXX_add_YYY() functions,
right?

One does not need to do so. However, if you have a large chunk of dissection code that only puts stuff into the protocol tree, and doesn't get any data or update any offsets necessary for calling subdissectors (which is the case for just about everything in a dissector that has no subdissectors, and may be true for stuff even in a dissector that has subdissectors), it might be less expensive to skip all that work rather than calling the "proto_XXX_add_YYY" functions - especially if it's a "proto_XXX_add_YYY_format" function and there's a significant amount of work involved in preparing the arguments to use with the format string.