On Mon, Aug 04, 2008 at 11:54:25AM +1000, Dave Chinner wrote:
> > I'm not sure
> > what to do with move_* - these are the most ugly helpers, so maybe
> > we should just make them memmove wrappers in the style of copy_
> > and leave all addressing to the callers.
>
> Yes, it would be nice to have them use the same interface. If
> we do that, then there's no real point for having a copy vs move
> distinction - we could just make everything use the
> memmove version and drop one of the interfaces altogether....
I've actually come up with another variant. Since what we do in the
memmove case is to move a number of entries in a single block up or down
one position I've added the following helper:
STATIC void
xfs_btree_shift_keys(
struct xfs_btree_cur *cur,
union xfs_btree_key *key
int dir,
int numkeys)
{
char *dst_key;
ASSERT(numkeys >= 0);
ASSERT(dir == 1 || dir == -1);
dst_key = (char *)key + (dir * cur->bc_ops->key_len);
memmove(dst_key, key, numkeys * cur->bc_ops->key_len);
}
and the same for ptrs and recs. This follows the original code in
spirit and is quite readable.
|