[blivet:master 03/18] Do not compare the same two values twice.
mulhern
amulhern at redhat.com
Mon Jan 5 15:03:21 UTC 2015
If x and y are Sizes, not (x < y) implies x >= y.
Write out the formula the if-statement implements in a comment, in case
readers of the code do not understand the semantics of elif or Size().
Signed-off-by: mulhern <amulhern at redhat.com>
---
blivet/devicelibs/swap.py | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/blivet/devicelibs/swap.py b/blivet/devicelibs/swap.py
index bcc0308..93ae64e 100644
--- a/blivet/devicelibs/swap.py
+++ b/blivet/devicelibs/swap.py
@@ -142,14 +142,20 @@ def swapSuggestion(quiet=False, hibernation=False, disk_space=None):
eight_GiB = Size("8GiB")
sixtyfour_GiB = Size("64 GiB")
- #chart suggested in the discussion with other teams
+ # the succeeding if-statement implements the following formula for
+ # suggested swap size.
+ #
+ # swap(mem) = 2 * mem, if mem < 2 GiB
+ # = mem, if 2 GiB <= mem < 8 GiB
+ # = mem / 2, if 8 GIB <= mem < 64 GiB
+ # = 4 GiB, if mem >= 64 GiB
if mem < two_GiB:
swap = 2 * mem
- elif two_GiB <= mem < eight_GiB:
+ elif mem < eight_GiB:
swap = mem
- elif eight_GiB <= mem < sixtyfour_GiB:
+ elif mem < sixtyfour_GiB:
swap = mem / 2
else:
--
1.9.3
More information about the anaconda-patches
mailing list