hphp/runtime/base/packed-array.cpp
/*
 * Get the maximum possible capacity without reallocation. Return 0 if we don't
 * have a quick way to get a better cap. Currently this only works for caps
 * within kPackedCapCodeThreshold. It should be pretty fast.
 */
Get the maximum possible capacity without reallocation. Return 0 if we don't
have a quick way to get a better cap. Currently this only works for caps
within kPackedCapCodeThreshold. It should be pretty fast.
Get the maximum possible capacity without reallocation . Return 0 if we don ' t have a quick way to get a better cap . Currently this only works for caps within kPackedCapCodeThreshold . It should be pretty fast .
uint32_t PackedArray::getMaxCapInPlaceFast(uint32_t cap) {
  if (UNLIKELY(cap > kPackedCapCodeThreshold)) {
    return 0;
  }
  static_assert(sizeof(TypedValue) == 16, "sizeof TypedValue changed?");
  static_assert(sizeof(ArrayData) == 16, "sizeof ArrayData changed?");
  assert((cap + 1) * 16U <= kMaxSmartSize);
  uint32_t newCap = (MemoryManager::smartSizeClass((cap + 1) << 4) >> 4) - 1;
  if (UNLIKELY(newCap > kPackedCapCodeThreshold)) {
    newCap &= ~0xFFU;
  }
  assert(newCap >= cap);
  return newCap > cap ? newCap : 0;
}
uint32_t PackedArray :: getMaxCapInPlaceFast ( uint32_t cap ) { if ( UNLIKELY ( cap > kPackedCapCodeThreshold ) ) { return 0 ; } static_assert ( sizeof ( TypedValue ) == 16 , " " ) ; static_assert ( sizeof ( ArrayData ) == 16 , " " ) ; assert ( ( cap + 1 ) * 16U <= kMaxSmartSize ) ; uint32_t newCap = ( MemoryManager :: smartSizeClass ( ( cap + 1 ) << 4 ) >> 4 ) - 1 ; if ( UNLIKELY ( newCap > kPackedCapCodeThreshold ) ) { newCap &= ~ 0xFFU ; } assert ( newCap >= cap ) ; return newCap > cap ? newCap : 0 ; }
Get the maximum possible capacity without reallocation.
Get the maximum possible capacity without reallocation .