Skip to content

Commit 268a5c5

Browse files
author
Florian Plaza Oñate
committed
Remove duplicated code
1 parent c5cf125 commit 268a5c5

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

inst/include/Rcpp/vector/DimNameProxy.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,17 @@ namespace internal{
3434
data_(other.data_), dim_(other.dim_) {}
3535

3636
inline DimNameProxy& operator=(SEXP other) {
37-
SEXP dim = Rf_getAttrib(data_, R_DimSymbol);
38-
if (INTEGER(dim)[dim_] != Rf_length(other)) {
37+
SEXP dims = Rf_getAttrib(data_, R_DimSymbol);
38+
if (INTEGER(dims)[dim_] != Rf_length(other)) {
3939
std::stringstream s;
4040
s << "dimension extent is '"
41-
<< INTEGER(dim)[dim_]
41+
<< INTEGER(dims)[dim_]
4242
<< "' while length of names is '"
4343
<< Rf_length(other)
4444
<< "'";
4545
stop(s.str());
4646
}
4747
SEXP dimnames = Rf_getAttrib(data_, R_DimNamesSymbol);
48-
SEXP dims = Rf_getAttrib(data_, R_DimSymbol);
4948
if (Rf_isNull(dimnames)) {
5049
Shield<SEXP> new_dimnames(Rf_allocVector(VECSXP, Rf_length(dims)));
5150
SET_VECTOR_ELT(new_dimnames, dim_, other);
@@ -55,20 +54,20 @@ namespace internal{
5554
}
5655
return *this;
5756
}
57+
5858

59-
inline DimNameProxy& operator=(const DimNameProxy& other) {
60-
SEXP dim = Rf_getAttrib(data_, R_DimSymbol);
61-
if (INTEGER(dim)[dim_] != INTEGER(dim)[other.dim_]) {
59+
inline DimNameProxy& operator=(const DimNameProxy& other) {
60+
SEXP dims = Rf_getAttrib(data_, R_DimSymbol);
61+
if (INTEGER(dims)[dim_] != INTEGER(dims)[other.dim_]) {
6262
std::stringstream s;
6363
s << "dimension extent is '"
64-
<< INTEGER(dim)[dim_]
64+
<< INTEGER(dims)[dim_]
6565
<< "' while length of names is '"
66-
<< INTEGER(dim)[other.dim_]
66+
<< INTEGER(dims)[other.dim_]
6767
<< "'";
6868
stop(s.str());
6969
}
7070
SEXP dimnames = Rf_getAttrib(data_, R_DimNamesSymbol);
71-
SEXP dims = Rf_getAttrib(data_, R_DimSymbol);
7271
SEXP other_dimnames = SEXP(other);
7372
if (Rf_isNull(dimnames)) {
7473
Shield<SEXP> new_dimnames(Rf_allocVector(VECSXP, Rf_length(dims)));
@@ -79,6 +78,7 @@ namespace internal{
7978
}
8079
return *this;
8180
}
81+
8282

8383

8484
inline operator SEXP() const {

0 commit comments

Comments
 (0)