diff options
| author | Michel Lespinasse <[email protected]> | 2012-10-08 16:30:42 -0700 |
|---|---|---|
| committer | Linus Torvalds <[email protected]> | 2012-10-09 16:22:33 +0900 |
| commit | 1f0528653e41ec230c60f5738820e8a544731399 (patch) | |
| tree | f07f4eb1ed58122b810b586839833e0c015b681c /tools/perf/scripts/python | |
| parent | 910a742d4ba863848c7283d69c21bfa779d3b9a8 (diff) | |
rbtree: break out of rb_insert_color loop after tree rotation
It is a well known property of rbtrees that insertion never requires more
than two tree rotations. In our implementation, after one loop iteration
identified one or two necessary tree rotations, we would iterate and look
for more. However at that point the node's parent would always be black,
which would cause us to exit the loop.
We can make the code flow more obvious by just adding a break statement
after the tree rotations, where we know we are done. Additionally, in the
cases where two tree rotations are necessary, we don't have to update the
'node' pointer as it wouldn't be used until the next loop iteration, which
we now avoid due to this break statement.
Signed-off-by: Michel Lespinasse <[email protected]>
Cc: Andrea Arcangeli <[email protected]>
Acked-by: David Woodhouse <[email protected]>
Cc: Rik van Riel <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Daniel Santos <[email protected]>
Cc: Jens Axboe <[email protected]>
Cc: "Eric W. Biederman" <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Diffstat (limited to 'tools/perf/scripts/python')
0 files changed, 0 insertions, 0 deletions