litho-core/src/main/java/com/facebook/litho/Edges.java [51:98]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  public boolean set(YogaEdge yogaEdge, float value) {
    final int edgeIntValue = yogaEdge.intValue();
    if (!floatsEqual(getRaw(edgeIntValue), value)) {
      final byte edgeIndex = getIndex(edgeIntValue);

      // If we need to "unset" a previously set edge.
      if (YogaConstants.isUndefined(value)) {
        // UNSET index:
        // Set the 4 bits representing the edge as undefined ('1111').
        mEdgesToValuesIndex |= ((long) UNDEFINED_INDEX << (edgeIntValue * 4));
        mValues[edgeIndex] = YogaConstants.UNDEFINED;

        // If we need to insert a new edge value.
      } else if (edgeIndex == UNDEFINED_INDEX) {
        final byte newIndex = getFirstAvailableIndex();
        if (newIndex >= EDGES_LENGTH) {
          throw new IllegalStateException(
              "The newIndex for the array cannot be bigger than the amount of Yoga Edges.");
        }
        // SETS index:
        // Clear the bits at the index position.
        mEdgesToValuesIndex &= ~((long) (0xF) << (edgeIntValue * 4));
        // Then set the actual 4 bits value of the index. Leaving this as two steps for clarity.
        mEdgesToValuesIndex |= ((long) newIndex << (edgeIntValue * 4));
        mValues[newIndex] = value;

        // Otherwise we need to overwrite an existing value.
      } else {
        mValues[edgeIndex] = value;
      }

      // 1. It moves the right most 3 "4bits set" represeting ALL, VERTICAL and HORIZONTAL
      //    to the first 3 "4bits set" position of our long array (0xFFF).
      // 2. It converts the array from long to int.
      // 3. It inverts the bits of the current array. UNDEFINED_INDEX is 0xF or "1111".
      //    When an UNDEFINED_INDEX is inverted, we expect all zeros "0000".
      // 4. Now the inverted array is masked with 0xFFF to get only the values we
      //    are interested into.
      // 5. If the result is equal to 0, we know that ALL, VERTICAL and HORIZONTAL were
      //    all containing UNDEFINED_INDEXes. If that's not the case, we have an alias
      //    set and will set the mHasAliasesSet flag to true.
      mHasAliasesSet = (~((int) (mEdgesToValuesIndex >> ALIASES_RIGHT_SHIFT)) & ALIASES_MASK) != 0;

      return true;
    }

    return false;
  }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



litho-rendercore-yoga/src/main/java/com/facebook/rendercore/Edges.java [50:97]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  public boolean set(YogaEdge yogaEdge, float value) {
    final int edgeIntValue = yogaEdge.intValue();
    if (!floatsEqual(getRaw(edgeIntValue), value)) {
      final byte edgeIndex = getIndex(edgeIntValue);

      // If we need to "unset" a previously set edge.
      if (YogaConstants.isUndefined(value)) {
        // UNSET index:
        // Set the 4 bits representing the edge as undefined ('1111').
        mEdgesToValuesIndex |= ((long) UNDEFINED_INDEX << (edgeIntValue * 4));
        mValues[edgeIndex] = YogaConstants.UNDEFINED;

        // If we need to insert a new edge value.
      } else if (edgeIndex == UNDEFINED_INDEX) {
        final byte newIndex = getFirstAvailableIndex();
        if (newIndex >= EDGES_LENGTH) {
          throw new IllegalStateException(
              "The newIndex for the array cannot be bigger than the amount of Yoga Edges.");
        }
        // SETS index:
        // Clear the bits at the index position.
        mEdgesToValuesIndex &= ~((long) (0xF) << (edgeIntValue * 4));
        // Then set the actual 4 bits value of the index. Leaving this as two steps for clarity.
        mEdgesToValuesIndex |= ((long) newIndex << (edgeIntValue * 4));
        mValues[newIndex] = value;

        // Otherwise we need to overwrite an existing value.
      } else {
        mValues[edgeIndex] = value;
      }

      // 1. It moves the right most 3 "4bits set" represeting ALL, VERTICAL and HORIZONTAL
      //    to the first 3 "4bits set" position of our long array (0xFFF).
      // 2. It converts the array from long to int.
      // 3. It inverts the bits of the current array. UNDEFINED_INDEX is 0xF or "1111".
      //    When an UNDEFINED_INDEX is inverted, we expect all zeros "0000".
      // 4. Now the inverted array is masked with 0xFFF to get only the values we
      //    are interested into.
      // 5. If the result is equal to 0, we know that ALL, VERTICAL and HORIZONTAL were
      //    all containing UNDEFINED_INDEXes. If that's not the case, we have an alias
      //    set and will set the mHasAliasesSet flag to true.
      mHasAliasesSet = (~((int) (mEdgesToValuesIndex >> ALIASES_RIGHT_SHIFT)) & ALIASES_MASK) != 0;

      return true;
    }

    return false;
  }
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



