Skip to content

Commit ca16f82

Browse files
author
Jonathan Marshall
committed
adds empty() to [const_]string_proxy for more efficient checks for empty string
1 parent 01bd959 commit ca16f82

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

inst/include/Rcpp/vector/const_string_proxy.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ namespace internal{
9393
inline iterator begin() const { return CHAR( STRING_ELT( *parent, index ) ) ; }
9494
inline iterator end() const { return begin() + size() ; }
9595
inline int size() const { return strlen( begin() ) ; }
96+
inline bool empty() const { return *begin() == '\0' ; }
9697
inline reference operator[]( int n ){ return *( begin() + n ) ; }
9798

9899
bool operator==( const char* other){

inst/include/Rcpp/vector/string_proxy.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ namespace internal{
158158
inline iterator begin() const { return CHAR( STRING_ELT( *parent, index ) ) ; }
159159
inline iterator end() const { return begin() + size() ; }
160160
inline int size() const { return strlen( begin() ) ; }
161+
inline bool empty() const { return *begin() == '\0' ; }
161162
inline reference operator[]( int n ){ return *( begin() + n ) ; }
162163

163164
template <typename UnaryOperator>

0 commit comments

Comments
 (0)