Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 14 | pmbaty | 1 | //===- Arrays.h ------------------------------------------------*- C++ -*-===// |
| 2 | // |
||
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
||
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
||
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
||
| 6 | // |
||
| 7 | //===----------------------------------------------------------------------===// |
||
| 8 | |||
| 9 | #ifndef LLD_ARRAYS_H |
||
| 10 | #define LLD_ARRAYS_H |
||
| 11 | |||
| 12 | #include "llvm/ADT/ArrayRef.h" |
||
| 13 | |||
| 14 | #include <vector> |
||
| 15 | |||
| 16 | namespace lld { |
||
| 17 | // Split one uint8 array into small pieces of uint8 arrays. |
||
| 18 | inline std::vector<llvm::ArrayRef<uint8_t>> split(llvm::ArrayRef<uint8_t> arr, |
||
| 19 | size_t chunkSize) { |
||
| 20 | std::vector<llvm::ArrayRef<uint8_t>> ret; |
||
| 21 | while (arr.size() > chunkSize) { |
||
| 22 | ret.push_back(arr.take_front(chunkSize)); |
||
| 23 | arr = arr.drop_front(chunkSize); |
||
| 24 | } |
||
| 25 | if (!arr.empty()) |
||
| 26 | ret.push_back(arr); |
||
| 27 | return ret; |
||
| 28 | } |
||
| 29 | |||
| 30 | } // namespace lld |
||
| 31 | |||
| 32 | #endif |