| 1999 | } |
| 2000 | |
| 2001 | void MutableBorrowingLiteral::CopyPieceSubtree(const Shape& shape, |
| 2002 | Piece* src_piece, |
| 2003 | Piece* dest_piece) { |
| 2004 | DCHECK(ShapeUtil::Equal(src_piece->subshape(), dest_piece->subshape())) |
| 2005 | << "src_piece has shape: " |
| 2006 | << ShapeUtil::HumanString(src_piece->subshape()) |
| 2007 | << "dest_piece has shape: " |
| 2008 | << ShapeUtil::HumanString(dest_piece->subshape()); |
| 2009 | if (shape.IsTuple()) { |
| 2010 | for (int i = 0; i < ShapeUtil::TupleElementCount(shape); ++i) { |
| 2011 | const Shape& subshape = shape.tuple_shapes(i); |
| 2012 | |
| 2013 | auto child_piece = Piece(); |
| 2014 | child_piece.set_subshape(&subshape); |
| 2015 | |
| 2016 | CopyPieceSubtree(subshape, &src_piece->child(i), &child_piece); |
| 2017 | |
| 2018 | dest_piece->emplace_back(std::move(child_piece)); |
| 2019 | } |
| 2020 | } else if (shape.IsArray()) { |
| 2021 | dest_piece->set_buffer(src_piece->buffer()); |
| 2022 | } else { |
| 2023 | // If the shape is neither an array nor tuple, then it must be |
| 2024 | // zero-sized. Otherwise, some memory needs to be allocated for it. |
| 2025 | CHECK_EQ(dest_piece->size_bytes(), 0); |
| 2026 | } |
| 2027 | } |
| 2028 | |
| 2029 | MutableLiteralBase::~MutableLiteralBase() {} |
| 2030 |
nothing calls this directly
no test coverage detected