Re: pack in structure or not?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Sun, Jul 23, 2006 at 05:26:14PM +0400, Paul Drynoff wrote:
> Reading the kernel code I see code like this
> int foo(int i1, void *p1, int i2, int i3, many parameters);
> 
> and also like this
> 
> struct foo_request req = {
> .i1 = i1_expression,
> .i2 = i2_expression,
> ...
> };
> 
> The second variant is much more understandable, but what variant is faster?
> Or speed is not so important as clearness?

You mean passing structures to functions rather then tons of single
arguments?

If you pass the structure through a pointer you have the lowest costs.
One pointer value instead of lots of value arguments.

But I don't think it increases the clarity if you pack up all function
arguments that have more then 2 values.

Hannes

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux