This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 1/3] Adding a some new probes to the networking.stp tapset


On 09/21/2009 10:46 AM, Breno Leitao wrote:
> David, 
> 
> Thanks for the review. 
> 
> David Smith wrote:
>> So, I think it would be better to trade off the six assignments and the
>> call to the _dwarf_tvar_get_dev_* and make separate sets of temporary
>> variables.  You'll end up increasing the number of temporaries that way,
>> but it should execute faster if only one of the mac addresses is used.
> 
> Do you mean something like: 
> 
> +	old_zero = $dev->dev_addr[0]
> +	old_one =  $dev->dev_addr[1]
> +	old_two =  $dev->dev_addr[2]
> +	old_three =$dev->dev_addr[3] 
> +	old_four = $dev->dev_addr[4]
> +	old_five = $dev->dev_addr[5]
> +	old_mac = sprintf("%02x:%02x:%02x:%02x:%02x:%02x",
> +			 old_zero, old_one, old_two, old_three, old_four, old_five)
> +
> +	// New MAC Address
> +	new_zero = $sa->sa_data[0]
> +	new_one  = $sa->sa_data[1]
> +	new_two  = $sa->sa_data[2]
> +	new_three =$sa->sa_data[3] 
> +	new_four  =$sa->sa_data[4] 
> +	new_five = $sa->sa_data[5]
> +	new_mac = sprintf("%02x:%02x:%02x:%02x:%02x:%02x",
> +			 new_zero, new_one, new_two, new_three, new_four, new_five)

Yes, except Josh fixed the problem in an even better manner by avoiding
the temporaries all together, like this:

        // Old MAC Address
        old_mac = sprintf("%02x:%02x:%02x:%02x:%02x:%02x",
                          $dev->dev_addr[0], $dev->dev_addr[1],
                          $dev->dev_addr[2], $dev->dev_addr[3],
                          $dev->dev_addr[4], $dev->dev_addr[5])

        // New MAC Address
        new_mac = sprintf("%02x:%02x:%02x:%02x:%02x:%02x",
                          $sa->sa_data[0], $sa->sa_data[1],
                          $sa->sa_data[2], $sa->sa_data[3],
                          $sa->sa_data[4], $sa->sa_data[5])

-- 
David Smith
dsmith@redhat.com
Red Hat
http://www.redhat.com
256.217.0141 (direct)
256.837.0057 (fax)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]