mirror of
https://github.com/nicbarker/clay.git
synced 2025-04-18 20:28:01 +00:00
Remove unnecessary float compares
This commit is contained in:
parent
8f87b7c712
commit
8195df36ad
18
clay.h
18
clay.h
@ -2025,14 +2025,6 @@ bool Clay__FloatEqual(float left, float right) {
|
|||||||
return subtracted < CLAY__EPSILON && subtracted > -CLAY__EPSILON;
|
return subtracted < CLAY__EPSILON && subtracted > -CLAY__EPSILON;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Clay__FloatGreaterThan(float left, float right) {
|
|
||||||
return left > (right + CLAY__EPSILON);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Clay__FloatLessThan(float left, float right) {
|
|
||||||
return (left + CLAY__EPSILON) < right;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Clay__SizeContainersAlongAxis(bool xAxis) {
|
void Clay__SizeContainersAlongAxis(bool xAxis) {
|
||||||
Clay_Context* context = Clay_GetCurrentContext();
|
Clay_Context* context = Clay_GetCurrentContext();
|
||||||
Clay__int32_tArray bfsBuffer = context->layoutElementChildrenBuffer;
|
Clay__int32_tArray bfsBuffer = context->layoutElementChildrenBuffer;
|
||||||
@ -2140,11 +2132,12 @@ void Clay__SizeContainersAlongAxis(bool xAxis) {
|
|||||||
for (int childIndex = 0; childIndex < resizableContainerBuffer.length; childIndex++) {
|
for (int childIndex = 0; childIndex < resizableContainerBuffer.length; childIndex++) {
|
||||||
Clay_LayoutElement *child = Clay_LayoutElementArray_Get(&context->layoutElements, Clay__int32_tArray_GetValue(&resizableContainerBuffer, childIndex));
|
Clay_LayoutElement *child = Clay_LayoutElementArray_Get(&context->layoutElements, Clay__int32_tArray_GetValue(&resizableContainerBuffer, childIndex));
|
||||||
float childSize = xAxis ? child->dimensions.width : child->dimensions.height;
|
float childSize = xAxis ? child->dimensions.width : child->dimensions.height;
|
||||||
if (Clay__FloatGreaterThan(childSize, largest)) {
|
if (Clay__FloatEqual(childSize, largest)) { continue; }
|
||||||
|
if (childSize > largest) {
|
||||||
secondLargest = largest;
|
secondLargest = largest;
|
||||||
largest = childSize;
|
largest = childSize;
|
||||||
}
|
}
|
||||||
if (Clay__FloatLessThan(childSize, largest)) {
|
if (childSize < largest) {
|
||||||
secondLargest = CLAY__MAX(secondLargest, childSize);
|
secondLargest = CLAY__MAX(secondLargest, childSize);
|
||||||
widthToAdd = secondLargest - largest;
|
widthToAdd = secondLargest - largest;
|
||||||
}
|
}
|
||||||
@ -2183,11 +2176,12 @@ void Clay__SizeContainersAlongAxis(bool xAxis) {
|
|||||||
for (int childIndex = 0; childIndex < resizableContainerBuffer.length; childIndex++) {
|
for (int childIndex = 0; childIndex < resizableContainerBuffer.length; childIndex++) {
|
||||||
Clay_LayoutElement *child = Clay_LayoutElementArray_Get(&context->layoutElements, Clay__int32_tArray_GetValue(&resizableContainerBuffer, childIndex));
|
Clay_LayoutElement *child = Clay_LayoutElementArray_Get(&context->layoutElements, Clay__int32_tArray_GetValue(&resizableContainerBuffer, childIndex));
|
||||||
float childSize = xAxis ? child->dimensions.width : child->dimensions.height;
|
float childSize = xAxis ? child->dimensions.width : child->dimensions.height;
|
||||||
if (Clay__FloatLessThan(childSize, smallest)) {
|
if (Clay__FloatEqual(childSize, smallest)) { continue; }
|
||||||
|
if (childSize < smallest) {
|
||||||
secondSmallest = smallest;
|
secondSmallest = smallest;
|
||||||
smallest = childSize;
|
smallest = childSize;
|
||||||
}
|
}
|
||||||
if (Clay__FloatGreaterThan(childSize, smallest)) {
|
if (childSize > smallest) {
|
||||||
secondSmallest = CLAY__MIN(secondSmallest, childSize);
|
secondSmallest = CLAY__MIN(secondSmallest, childSize);
|
||||||
widthToAdd = secondSmallest - smallest;
|
widthToAdd = secondSmallest - smallest;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user