> >> This would save some CPU cycles for the repeated le64_to_cpu() and for
> >> the memcpy(). The number of lines of code is equal for both ways.
> > 
> > Hmm?  It would be many fewer lines of code.
> 
> Are you thinking of something shorter than the following?

That's better, yeah, but there's still some room left to go.  Almost all
of the remaining code is boiler-plate iteration that could be done with
a for(;;).

This could be a mini OCC contest! :)

> offset = (unsigned long)ptr;
> subid = cpu_to_le64(subid);

> while (sub_item_len > 0) {
>       if (memcmp_extent_buffer(eb, &subid, offset,
>                                sizeof(subid)) == 0) {
>               ret = 0;
>               break;
>       }
>       offset += sizeof(subid);
>       sub_item_len--;
> }

roughly:

unsigned long end = offset + sub_item_len;

for (ret = 1; offset < end && ret; offset += sizeof(subid))
        ret = !!memcmp_extent_buffer(eb, &subid, offset,
                                     sizeof(subid));

- z
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to