Suggest the compiler to inline smaller functions

Reviewed By: gkassabli

Differential Revision: D4074580

fbshipit-source-id: 69b63fadf2011cb688af58f09d67c2cb711a0e20
This commit is contained in:
Emil Sjolander 2016-10-25 10:31:56 -07:00 коммит произвёл Facebook Github Bot
Родитель 770a9f20a2
Коммит 942f724166
1 изменённых файлов: 31 добавлений и 27 удалений

Просмотреть файл

@ -113,9 +113,9 @@ static CSSLogger gLogger = &_csslayoutAndroidLog;
static CSSLogger gLogger = &printf; static CSSLogger gLogger = &printf;
#endif #endif
static float computedEdgeValue(const float edges[CSSEdgeCount], static inline float computedEdgeValue(const float edges[CSSEdgeCount],
const CSSEdge edge, const CSSEdge edge,
const float defaultValue) { const float defaultValue) {
CSS_ASSERT(edge <= CSSEdgeEnd, "Cannot get computed value of multi-edge shorthands"); CSS_ASSERT(edge <= CSSEdgeEnd, "Cannot get computed value of multi-edge shorthands");
if (!CSSValueIsUndefined(edges[edge])) { if (!CSSValueIsUndefined(edges[edge])) {
@ -272,7 +272,7 @@ CSSNodeRef CSSNodeGetChild(const CSSNodeRef node, const uint32_t index) {
return CSSNodeListGet(node->children, index); return CSSNodeListGet(node->children, index);
} }
uint32_t CSSNodeChildCount(const CSSNodeRef node) { inline uint32_t CSSNodeChildCount(const CSSNodeRef node) {
return CSSNodeListCount(node->children); return CSSNodeListCount(node->children);
} }
@ -287,7 +287,7 @@ bool CSSNodeIsDirty(const CSSNodeRef node) {
return node->isDirty; return node->isDirty;
} }
float CSSNodeStyleGetFlexGrow(CSSNodeRef node) { inline float CSSNodeStyleGetFlexGrow(CSSNodeRef node) {
if (!CSSValueIsUndefined(node->style.flexGrow)) { if (!CSSValueIsUndefined(node->style.flexGrow)) {
return node->style.flexGrow; return node->style.flexGrow;
} }
@ -297,7 +297,7 @@ float CSSNodeStyleGetFlexGrow(CSSNodeRef node) {
return 0; return 0;
} }
float CSSNodeStyleGetFlexShrink(CSSNodeRef node) { inline float CSSNodeStyleGetFlexShrink(CSSNodeRef node) {
if (!CSSValueIsUndefined(node->style.flexShrink)) { if (!CSSValueIsUndefined(node->style.flexShrink)) {
return node->style.flexShrink; return node->style.flexShrink;
} }
@ -307,7 +307,7 @@ float CSSNodeStyleGetFlexShrink(CSSNodeRef node) {
return 0; return 0;
} }
float CSSNodeStyleGetFlexBasis(CSSNodeRef node) { inline float CSSNodeStyleGetFlexBasis(CSSNodeRef node) {
if (!CSSValueIsUndefined(node->style.flexBasis)) { if (!CSSValueIsUndefined(node->style.flexBasis)) {
return node->style.flexBasis; return node->style.flexBasis;
} }
@ -416,11 +416,11 @@ bool layoutNodeInternal(const CSSNodeRef node,
const bool performLayout, const bool performLayout,
const char *reason); const char *reason);
bool CSSValueIsUndefined(const float value) { inline bool CSSValueIsUndefined(const float value) {
return isnan(value); return isnan(value);
} }
static bool eq(const float a, const float b) { static inline bool eq(const float a, const float b) {
if (CSSValueIsUndefined(a)) { if (CSSValueIsUndefined(a)) {
return CSSValueIsUndefined(b); return CSSValueIsUndefined(b);
} }
@ -628,15 +628,15 @@ static const CSSDimension dim[4] = {
[CSSFlexDirectionRowReverse] = CSSDimensionWidth, [CSSFlexDirectionRowReverse] = CSSDimensionWidth,
}; };
static bool isRowDirection(const CSSFlexDirection flexDirection) { static inline bool isRowDirection(const CSSFlexDirection flexDirection) {
return flexDirection == CSSFlexDirectionRow || flexDirection == CSSFlexDirectionRowReverse; return flexDirection == CSSFlexDirectionRow || flexDirection == CSSFlexDirectionRowReverse;
} }
static bool isColumnDirection(const CSSFlexDirection flexDirection) { static inline bool isColumnDirection(const CSSFlexDirection flexDirection) {
return flexDirection == CSSFlexDirectionColumn || flexDirection == CSSFlexDirectionColumnReverse; return flexDirection == CSSFlexDirectionColumn || flexDirection == CSSFlexDirectionColumnReverse;
} }
static float getLeadingMargin(const CSSNodeRef node, const CSSFlexDirection axis) { static inline float getLeadingMargin(const CSSNodeRef node, const CSSFlexDirection axis) {
if (isRowDirection(axis) && !CSSValueIsUndefined(node->style.margin[CSSEdgeStart])) { if (isRowDirection(axis) && !CSSValueIsUndefined(node->style.margin[CSSEdgeStart])) {
return node->style.margin[CSSEdgeStart]; return node->style.margin[CSSEdgeStart];
} }
@ -708,30 +708,32 @@ static float getTrailingBorder(const CSSNodeRef node, const CSSFlexDirection axi
return 0; return 0;
} }
static float getLeadingPaddingAndBorder(const CSSNodeRef node, const CSSFlexDirection axis) { static inline float getLeadingPaddingAndBorder(const CSSNodeRef node, const CSSFlexDirection axis) {
return getLeadingPadding(node, axis) + getLeadingBorder(node, axis); return getLeadingPadding(node, axis) + getLeadingBorder(node, axis);
} }
static float getTrailingPaddingAndBorder(const CSSNodeRef node, const CSSFlexDirection axis) { static inline float getTrailingPaddingAndBorder(const CSSNodeRef node,
const CSSFlexDirection axis) {
return getTrailingPadding(node, axis) + getTrailingBorder(node, axis); return getTrailingPadding(node, axis) + getTrailingBorder(node, axis);
} }
static float getMarginAxis(const CSSNodeRef node, const CSSFlexDirection axis) { static inline float getMarginAxis(const CSSNodeRef node, const CSSFlexDirection axis) {
return getLeadingMargin(node, axis) + getTrailingMargin(node, axis); return getLeadingMargin(node, axis) + getTrailingMargin(node, axis);
} }
static float getPaddingAndBorderAxis(const CSSNodeRef node, const CSSFlexDirection axis) { static inline float getPaddingAndBorderAxis(const CSSNodeRef node, const CSSFlexDirection axis) {
return getLeadingPaddingAndBorder(node, axis) + getTrailingPaddingAndBorder(node, axis); return getLeadingPaddingAndBorder(node, axis) + getTrailingPaddingAndBorder(node, axis);
} }
static CSSAlign getAlignItem(const CSSNodeRef node, const CSSNodeRef child) { static inline CSSAlign getAlignItem(const CSSNodeRef node, const CSSNodeRef child) {
if (child->style.alignSelf != CSSAlignAuto) { if (child->style.alignSelf != CSSAlignAuto) {
return child->style.alignSelf; return child->style.alignSelf;
} }
return node->style.alignItems; return node->style.alignItems;
} }
static CSSDirection resolveDirection(const CSSNodeRef node, const CSSDirection parentDirection) { static inline CSSDirection resolveDirection(const CSSNodeRef node,
const CSSDirection parentDirection) {
if (node->style.direction == CSSDirectionInherit) { if (node->style.direction == CSSDirectionInherit) {
return parentDirection > CSSDirectionInherit ? parentDirection : CSSDirectionLTR; return parentDirection > CSSDirectionInherit ? parentDirection : CSSDirectionLTR;
} else { } else {
@ -739,8 +741,8 @@ static CSSDirection resolveDirection(const CSSNodeRef node, const CSSDirection p
} }
} }
static CSSFlexDirection resolveAxis(const CSSFlexDirection flexDirection, static inline CSSFlexDirection resolveAxis(const CSSFlexDirection flexDirection,
const CSSDirection direction) { const CSSDirection direction) {
if (direction == CSSDirectionRTL) { if (direction == CSSDirectionRTL) {
if (flexDirection == CSSFlexDirectionRow) { if (flexDirection == CSSFlexDirectionRow) {
return CSSFlexDirectionRowReverse; return CSSFlexDirectionRowReverse;
@ -761,34 +763,34 @@ static CSSFlexDirection getCrossFlexDirection(const CSSFlexDirection flexDirecti
} }
} }
static bool isFlex(const CSSNodeRef node) { static inline bool isFlex(const CSSNodeRef node) {
return (node->style.positionType == CSSPositionTypeRelative && return (node->style.positionType == CSSPositionTypeRelative &&
(node->style.flexGrow != 0 || node->style.flexShrink != 0 || node->style.flex != 0)); (node->style.flexGrow != 0 || node->style.flexShrink != 0 || node->style.flex != 0));
} }
static float getDimWithMargin(const CSSNodeRef node, const CSSFlexDirection axis) { static inline float getDimWithMargin(const CSSNodeRef node, const CSSFlexDirection axis) {
return node->layout.measuredDimensions[dim[axis]] + getLeadingMargin(node, axis) + return node->layout.measuredDimensions[dim[axis]] + getLeadingMargin(node, axis) +
getTrailingMargin(node, axis); getTrailingMargin(node, axis);
} }
static bool isStyleDimDefined(const CSSNodeRef node, const CSSFlexDirection axis) { static inline bool isStyleDimDefined(const CSSNodeRef node, const CSSFlexDirection axis) {
const float value = node->style.dimensions[dim[axis]]; const float value = node->style.dimensions[dim[axis]];
return !CSSValueIsUndefined(value) && value >= 0.0; return !CSSValueIsUndefined(value) && value >= 0.0;
} }
static bool isLayoutDimDefined(const CSSNodeRef node, const CSSFlexDirection axis) { static inline bool isLayoutDimDefined(const CSSNodeRef node, const CSSFlexDirection axis) {
const float value = node->layout.measuredDimensions[dim[axis]]; const float value = node->layout.measuredDimensions[dim[axis]];
return !CSSValueIsUndefined(value) && value >= 0.0; return !CSSValueIsUndefined(value) && value >= 0.0;
} }
static bool isLeadingPosDefined(const CSSNodeRef node, const CSSFlexDirection axis) { static inline bool isLeadingPosDefined(const CSSNodeRef node, const CSSFlexDirection axis) {
return (isRowDirection(axis) && return (isRowDirection(axis) &&
!CSSValueIsUndefined( !CSSValueIsUndefined(
computedEdgeValue(node->style.position, CSSEdgeStart, CSSUndefined))) || computedEdgeValue(node->style.position, CSSEdgeStart, CSSUndefined))) ||
!CSSValueIsUndefined(computedEdgeValue(node->style.position, leading[axis], CSSUndefined)); !CSSValueIsUndefined(computedEdgeValue(node->style.position, leading[axis], CSSUndefined));
} }
static bool isTrailingPosDefined(const CSSNodeRef node, const CSSFlexDirection axis) { static inline bool isTrailingPosDefined(const CSSNodeRef node, const CSSFlexDirection axis) {
return (isRowDirection(axis) && return (isRowDirection(axis) &&
!CSSValueIsUndefined( !CSSValueIsUndefined(
computedEdgeValue(node->style.position, CSSEdgeEnd, CSSUndefined))) || computedEdgeValue(node->style.position, CSSEdgeEnd, CSSUndefined))) ||
@ -862,7 +864,9 @@ static float boundAxisWithinMinAndMax(const CSSNodeRef node,
// Like boundAxisWithinMinAndMax but also ensures that the value doesn't go // Like boundAxisWithinMinAndMax but also ensures that the value doesn't go
// below the // below the
// padding and border amount. // padding and border amount.
static float boundAxis(const CSSNodeRef node, const CSSFlexDirection axis, const float value) { static inline float boundAxis(const CSSNodeRef node,
const CSSFlexDirection axis,
const float value) {
return fmaxf(boundAxisWithinMinAndMax(node, axis, value), getPaddingAndBorderAxis(node, axis)); return fmaxf(boundAxisWithinMinAndMax(node, axis, value), getPaddingAndBorderAxis(node, axis));
} }