! * \brief Move or copy the ArrayObj to new address with the given capacity * \param capacity The capacity requirement of the new address */
| 710 | * \param capacity The capacity requirement of the new address |
| 711 | */ |
| 712 | ArrayObj* SwitchContainer(int64_t capacity) { |
| 713 | if (data_ == nullptr) { |
| 714 | data_ = ArrayObj::Empty(capacity); |
| 715 | } else if (data_.unique()) { |
| 716 | data_ = ArrayObj::MoveFrom(capacity, GetArrayObj()); |
| 717 | } else { |
| 718 | data_ = ArrayObj::CopyFrom(capacity, GetArrayObj()); |
| 719 | } |
| 720 | return static_cast<ArrayObj*>(data_.get()); |
| 721 | } |
| 722 | |
| 723 | /*! \brief Helper method for mutate/map |
| 724 | * |