Small cleanup to gradient index and hist. (#7668)

* Code comments.
* Const accessor to index.
* Remove some weird variables in the `Index` class.
* Simplify the `MemStackAllocator`.
This commit is contained in:
Jiaming Yuan
2022-02-23 11:37:21 +08:00
committed by GitHub
parent 49c74a5369
commit 6762c45494
12 changed files with 149 additions and 148 deletions

View File

@@ -266,9 +266,9 @@ class ColumnMatrix {
}
template <typename T>
inline void SetIndexAllDense(T *index, const GHistIndexMatrix &gmat,
const size_t nrow, const size_t nfeature,
const bool noMissingValues, int32_t n_threads) {
inline void SetIndexAllDense(T const* index, const GHistIndexMatrix& gmat, const size_t nrow,
const size_t nfeature, const bool noMissingValues,
int32_t n_threads) {
T* local_index = reinterpret_cast<T*>(&index_[0]);
/* missing values make sense only for column with type kDenseColumn,
@@ -313,7 +313,7 @@ class ColumnMatrix {
}
template<typename T>
inline void SetIndex(uint32_t* index, const GHistIndexMatrix& gmat,
inline void SetIndex(uint32_t const* index, const GHistIndexMatrix& gmat,
const size_t nfeature) {
std::vector<size_t> num_nonzeros;
num_nonzeros.resize(nfeature);