summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBart Van Assche <bart.vanassche@wdc.com>2018-08-22 13:22:12 -0700
committerBart Van Assche <bvanassche@acm.org>2018-08-22 18:59:24 -0700
commit1cf97788d4e533e4216160c2715f14596106e1e5 (patch)
tree49fde332d4b4aa35329f3ae410163b56b72aa1d3 /lib
parent15a4f4962fad9e1777bcc662b3391f521ace8c5b (diff)
downloadfio-1cf97788d4e533e4216160c2715f14596106e1e5.tar.gz
fio-1cf97788d4e533e4216160c2715f14596106e1e5.tar.bz2
lib/axmap: Optimize __axmap_set()
Since it is guaranteed that nr_bits <= BLOCKS_PER_UNIT and since axmap_set_fn() needs to be called only once to set that number of bits, remove the loop from __axmap_set(). Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/axmap.c19
1 files changed, 3 insertions, 16 deletions
diff --git a/lib/axmap.c b/lib/axmap.c
index 336d7048..e194e807 100644
--- a/lib/axmap.c
+++ b/lib/axmap.c
@@ -268,29 +268,16 @@ static bool axmap_set_fn(struct axmap_level *al, unsigned long offset,
static void __axmap_set(struct axmap *axmap, uint64_t bit_nr,
struct axmap_set_data *data)
{
- unsigned int set_bits, nr_bits = data->nr_bits;
+ unsigned int nr_bits = data->nr_bits;
if (bit_nr > axmap->nr_bits)
return;
else if (bit_nr + nr_bits > axmap->nr_bits)
nr_bits = axmap->nr_bits - bit_nr;
- set_bits = 0;
- while (nr_bits) {
- axmap_handler(axmap, bit_nr, axmap_set_fn, data);
- set_bits += data->set_bits;
+ assert(nr_bits <= BLOCKS_PER_UNIT);
- if (!data->set_bits ||
- data->set_bits != (BLOCKS_PER_UNIT - nr_bits))
- break;
-
- nr_bits -= data->set_bits;
- bit_nr += data->set_bits;
-
- data->nr_bits = nr_bits;
- }
-
- data->set_bits = set_bits;
+ axmap_handler(axmap, bit_nr, axmap_set_fn, data);
}
void axmap_set(struct axmap *axmap, uint64_t bit_nr)