diff options
author | Christoph Hellwig <hch@lst.de> | 2011-07-08 08:36:05 -0400 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2011-07-08 08:36:05 -0400 |
commit | 69ef921b55cc3788d1d2a27b33b27d04acd0090a (patch) | |
tree | bcc7c1f4b7f15628f122dfdb96f8d4d37f587e92 /fs/xfs/xfs_dir2_block.c | |
parent | 218106a1104c598011e5df9d9aac7e0416be03e6 (diff) |
xfs: byteswap constants instead of variables
Micro-optimize various comparisms by always byteswapping the constant
instead of the variable, which allows to do the swap at compile instead
of runtime.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Alex Elder <aelder@sgi.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Diffstat (limited to 'fs/xfs/xfs_dir2_block.c')
-rw-r--r-- | fs/xfs/xfs_dir2_block.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/fs/xfs/xfs_dir2_block.c b/fs/xfs/xfs_dir2_block.c index c9fdabe5e1ad..70fb0cb6bd69 100644 --- a/fs/xfs/xfs_dir2_block.c +++ b/fs/xfs/xfs_dir2_block.c | |||
@@ -109,7 +109,7 @@ xfs_dir2_block_addname( | |||
109 | /* | 109 | /* |
110 | * Check the magic number, corrupted if wrong. | 110 | * Check the magic number, corrupted if wrong. |
111 | */ | 111 | */ |
112 | if (unlikely(be32_to_cpu(hdr->magic) != XFS_DIR2_BLOCK_MAGIC)) { | 112 | if (unlikely(hdr->magic != cpu_to_be32(XFS_DIR2_BLOCK_MAGIC))) { |
113 | XFS_CORRUPTION_ERROR("xfs_dir2_block_addname", | 113 | XFS_CORRUPTION_ERROR("xfs_dir2_block_addname", |
114 | XFS_ERRLEVEL_LOW, mp, hdr); | 114 | XFS_ERRLEVEL_LOW, mp, hdr); |
115 | xfs_da_brelse(tp, bp); | 115 | xfs_da_brelse(tp, bp); |
@@ -255,7 +255,8 @@ xfs_dir2_block_addname( | |||
255 | highstale = lfloghigh = -1; | 255 | highstale = lfloghigh = -1; |
256 | fromidx >= 0; | 256 | fromidx >= 0; |
257 | fromidx--) { | 257 | fromidx--) { |
258 | if (be32_to_cpu(blp[fromidx].address) == XFS_DIR2_NULL_DATAPTR) { | 258 | if (blp[fromidx].address == |
259 | cpu_to_be32(XFS_DIR2_NULL_DATAPTR)) { | ||
259 | if (highstale == -1) | 260 | if (highstale == -1) |
260 | highstale = toidx; | 261 | highstale = toidx; |
261 | else { | 262 | else { |
@@ -352,12 +353,14 @@ xfs_dir2_block_addname( | |||
352 | else { | 353 | else { |
353 | for (lowstale = mid; | 354 | for (lowstale = mid; |
354 | lowstale >= 0 && | 355 | lowstale >= 0 && |
355 | be32_to_cpu(blp[lowstale].address) != XFS_DIR2_NULL_DATAPTR; | 356 | blp[lowstale].address != |
357 | cpu_to_be32(XFS_DIR2_NULL_DATAPTR); | ||
356 | lowstale--) | 358 | lowstale--) |
357 | continue; | 359 | continue; |
358 | for (highstale = mid + 1; | 360 | for (highstale = mid + 1; |
359 | highstale < be32_to_cpu(btp->count) && | 361 | highstale < be32_to_cpu(btp->count) && |
360 | be32_to_cpu(blp[highstale].address) != XFS_DIR2_NULL_DATAPTR && | 362 | blp[highstale].address != |
363 | cpu_to_be32(XFS_DIR2_NULL_DATAPTR) && | ||
361 | (lowstale < 0 || mid - lowstale > highstale - mid); | 364 | (lowstale < 0 || mid - lowstale > highstale - mid); |
362 | highstale++) | 365 | highstale++) |
363 | continue; | 366 | continue; |
@@ -899,7 +902,7 @@ xfs_dir2_leaf_to_block( | |||
899 | tp = args->trans; | 902 | tp = args->trans; |
900 | mp = dp->i_mount; | 903 | mp = dp->i_mount; |
901 | leaf = lbp->data; | 904 | leaf = lbp->data; |
902 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC); | 905 | ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAF1_MAGIC)); |
903 | ltp = xfs_dir2_leaf_tail_p(mp, leaf); | 906 | ltp = xfs_dir2_leaf_tail_p(mp, leaf); |
904 | /* | 907 | /* |
905 | * If there are data blocks other than the first one, take this | 908 | * If there are data blocks other than the first one, take this |
@@ -929,7 +932,7 @@ xfs_dir2_leaf_to_block( | |||
929 | goto out; | 932 | goto out; |
930 | } | 933 | } |
931 | hdr = dbp->data; | 934 | hdr = dbp->data; |
932 | ASSERT(be32_to_cpu(hdr->magic) == XFS_DIR2_DATA_MAGIC); | 935 | ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC)); |
933 | /* | 936 | /* |
934 | * Size of the "leaf" area in the block. | 937 | * Size of the "leaf" area in the block. |
935 | */ | 938 | */ |
@@ -971,7 +974,8 @@ xfs_dir2_leaf_to_block( | |||
971 | */ | 974 | */ |
972 | lep = xfs_dir2_block_leaf_p(btp); | 975 | lep = xfs_dir2_block_leaf_p(btp); |
973 | for (from = to = 0; from < be16_to_cpu(leaf->hdr.count); from++) { | 976 | for (from = to = 0; from < be16_to_cpu(leaf->hdr.count); from++) { |
974 | if (be32_to_cpu(leaf->ents[from].address) == XFS_DIR2_NULL_DATAPTR) | 977 | if (leaf->ents[from].address == |
978 | cpu_to_be32(XFS_DIR2_NULL_DATAPTR)) | ||
975 | continue; | 979 | continue; |
976 | lep[to++] = leaf->ents[from]; | 980 | lep[to++] = leaf->ents[from]; |
977 | } | 981 | } |