On Fri, 21 Jun 2013 09:11:38 -0700, Zach Brown wrote:
>>>> + offset = (unsigned long)ptr;
>>>> + while (sub_item_len > 0) {
>>>> + u64 data;
>>>> +
>>>> + read_extent_buffer(eb, &data, offset, sizeof(data));
>>>> + data = le64_to_cpu(data);
>>>> + if (data == subid) {
>>>> + ret = 0;
>>>> + break;
>>>> + }
>>>> + offset += sizeof(data);
>>>> + sub_item_len--;
>>>> + }
>>>
>>> This could be cleaned up a bit by comparing an on-stack little-endian
>>> input subid with each little-endian subid in the item with
>>> memcmp_extent_buffer().
>>
>> 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?
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--;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html