From 8fd14c710ce8133b5c62b2f6ebd68a6b7bc95b44 Mon Sep 17 00:00:00 2001 From: Emil Sjolander Date: Tue, 20 Sep 2016 10:16:15 -0700 Subject: [PATCH] Move justifyContent check into switch statement Summary: some general cleanup Reviewed By: lucasr Differential Revision: D3886861 fbshipit-source-id: 17ba2962016af34b5add3ce6d8355c9c305a35c0 --- CSSLayout/CSSLayout.c | 22 ++++++++++++---------- format.sh | 2 +- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/CSSLayout.c index 770ad45e..48cd7c45 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/CSSLayout.c @@ -1497,25 +1497,27 @@ static void layoutNodeImpl(const CSSNodeRef node, remainingFreeSpace = 0; } - // Use justifyContent to figure out how to allocate the remaining space - // available in the main axis. - if (justifyContent != CSSJustifyFlexStart) { - if (justifyContent == CSSJustifyCenter) { + switch (justifyContent) { + case CSSJustifyCenter: leadingMainDim = remainingFreeSpace / 2; - } else if (justifyContent == CSSJustifyFlexEnd) { + break; + case CSSJustifyFlexEnd: leadingMainDim = remainingFreeSpace; - } else if (justifyContent == CSSJustifySpaceBetween) { - remainingFreeSpace = fmaxf(remainingFreeSpace, 0); + break; + case CSSJustifySpaceBetween: if (itemsOnLine > 1) { - betweenMainDim = remainingFreeSpace / (itemsOnLine - 1); + betweenMainDim = fmaxf(remainingFreeSpace, 0) / (itemsOnLine - 1); } else { betweenMainDim = 0; } - } else if (justifyContent == CSSJustifySpaceAround) { + break; + case CSSJustifySpaceAround: // Space on the edges is half of the space between elements betweenMainDim = remainingFreeSpace / itemsOnLine; leadingMainDim = betweenMainDim / 2; - } + break; + default: + break; } float mainDim = leadingPaddingAndBorderMain + leadingMainDim; diff --git a/format.sh b/format.sh index 817d7fa3..4fae7ff9 100755 --- a/format.sh +++ b/format.sh @@ -6,7 +6,7 @@ clang-format \ AlignOperands: true, \ AllowAllParametersOfDeclarationOnNextLine: false, \ AllowShortBlocksOnASingleLine: false, \ - AllowShortCaseLabelsOnASingleLine: true, \ + AllowShortCaseLabelsOnASingleLine: false, \ AllowShortFunctionsOnASingleLine: false, \ AllowShortIfStatementsOnASingleLine: false, \ AllowShortLoopsOnASingleLine: false, \