Skip to content

Commit f6e212f

Browse files
committed
Unify const_iterator::operator*()
1 parent c54765c commit f6e212f

File tree

3 files changed

+4
-12
lines changed

3 files changed

+4
-12
lines changed

inst/include/cpp11/list.hpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,6 @@ inline bool r_vector<SEXP>::const_iterator::use_buf(bool is_altrep) {
5656
return false;
5757
}
5858

59-
template <>
60-
inline SEXP r_vector<SEXP>::const_iterator::operator*() const {
61-
return VECTOR_ELT(data_->data(), pos_);
62-
}
63-
6459
typedef r_vector<SEXP> list;
6560

6661
namespace writable {

inst/include/cpp11/r_vector.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -697,10 +697,12 @@ inline typename r_vector<T>::const_iterator r_vector<T>::find(
697697

698698
template <typename T>
699699
inline T r_vector<T>::const_iterator::operator*() const {
700-
if (data_->is_altrep()) {
700+
if (use_buf(data_->is_altrep())) {
701+
// Use pre-loaded buffer for compatible ALTREP types
701702
return static_cast<T>(buf_[pos_ - block_start_]);
702703
} else {
703-
return static_cast<T>(data_->data_p_[pos_]);
704+
// Otherwise pass through to normal retrieval method
705+
return data_->operator[](pos_);
704706
}
705707
}
706708

inst/include/cpp11/strings.hpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,6 @@ inline bool r_vector<r_string>::const_iterator::use_buf(bool is_altrep) {
4545
return false;
4646
}
4747

48-
template <>
49-
inline r_string r_vector<r_string>::const_iterator::operator*() const {
50-
return STRING_ELT(data_->data(), pos_);
51-
}
52-
5348
typedef r_vector<r_string> strings;
5449

5550
namespace writable {

0 commit comments

Comments
 (0)