From: Eric Sandeen <sandeen@sandeen.net>
To: xfs-oss <xfs@oss.sgi.com>
Subject: duplicate code in dir2
Date: Wed, 22 Jun 2011 10:24:02 -0500 [thread overview]
Message-ID: <4E020912.9020106@sandeen.net> (raw)
I was poking around with various code metrics, and found a fair bit of duplication in dir2 code (using "duplo").
Haven't really thought about how it might be factorable, but thought it might be interesting to share.
-Eric
/src/git/linux-2.6/fs/xfs/xfs_dir2_node.c(251)
/src/git/linux-2.6/fs/xfs/xfs_dir2_leaf.c(440)
if (index < be16_to_cpu(leaf->hdr.count))
memmove(lep + 1, lep,
(be16_to_cpu(leaf->hdr.count) - index) * sizeof(*lep));
lfloglow = index;
lfloghigh = be16_to_cpu(leaf->hdr.count);
be16_add_cpu(&leaf->hdr.count, 1);
else {
if (compact == 0) {
for (lowstale = index - 1;
lowstale >= 0 &&
be32_to_cpu(leaf->ents[lowstale].address) !=
XFS_DIR2_NULL_DATAPTR;
lowstale--)
continue;
for (highstale = index;
highstale < be16_to_cpu(leaf->hdr.count) &&
be32_to_cpu(leaf->ents[highstale].address) !=
XFS_DIR2_NULL_DATAPTR &&
(lowstale < 0 ||
index - lowstale - 1 >= highstale - index);
highstale++)
continue;
if (lowstale >= 0 &&
(highstale == be16_to_cpu(leaf->hdr.count) ||
index - lowstale - 1 < highstale - index)) {
/src/git/linux-2.6/fs/xfs/xfs_dir2_node.c(300)
/src/git/linux-2.6/fs/xfs/xfs_dir2_leaf.c(499)
if (index - lowstale - 1 > 0)
memmove(&leaf->ents[lowstale],
&leaf->ents[lowstale + 1],
(index - lowstale - 1) * sizeof(*lep));
lep = &leaf->ents[index - 1];
lfloglow = MIN(lowstale, lfloglow);
lfloghigh = MAX(index - 1, lfloghigh);
else {
/src/git/linux-2.6/fs/xfs/xfs_dir2_node.c(316)
/src/git/linux-2.6/fs/xfs/xfs_dir2_leaf.c(518)
if (highstale - index > 0)
memmove(&leaf->ents[index + 1],
&leaf->ents[index],
(highstale - index) * sizeof(*lep));
lep = &leaf->ents[index];
lfloglow = MIN(index, lfloglow);
lfloghigh = MAX(highstale, lfloghigh);
be16_add_cpu(&leaf->hdr.stale, -1);
lep->hashval = cpu_to_be32(args->hashval);
/src/git/linux-2.6/fs/xfs/xfs_dir2_node.c(582)
/src/git/linux-2.6/fs/xfs/xfs_dir2_leaf.c(1349)
for (lep = &leaf->ents[index]; index < be16_to_cpu(leaf->hdr.count) &&
be32_to_cpu(lep->hashval) == args->hashval;
lep++, index++) {
if (be32_to_cpu(lep->address) == XFS_DIR2_NULL_DATAPTR)
continue;
newdb = xfs_dir2_dataptr_to_db(mp, be32_to_cpu(lep->address));
if (newdb != curdb) {
/src/git/linux-2.6/fs/xfs/xfs_dir2_node.c(442)
/src/git/linux-2.6/fs/xfs/xfs_dir2_leaf.c(1349)
for (lep = &leaf->ents[index]; index < be16_to_cpu(leaf->hdr.count) &&
be32_to_cpu(lep->hashval) == args->hashval;
lep++, index++) {
if (be32_to_cpu(lep->address) == XFS_DIR2_NULL_DATAPTR)
continue;
newdb = xfs_dir2_dataptr_to_db(mp, be32_to_cpu(lep->address));
if (newdb != curdb) {
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next reply other threads:[~2011-06-22 15:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-22 15:24 Eric Sandeen [this message]
2011-06-22 15:25 ` duplicate code in dir2 Eric Sandeen
2011-06-23 11:03 ` Christoph Hellwig
2011-06-23 10:53 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4E020912.9020106@sandeen.net \
--to=sandeen@sandeen.net \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox