@@ -32,8 +32,8 @@ namespace internal{
32
32
DimNameProxy (SEXP data, int dim): data_(data), dim_(dim) {}
33
33
DimNameProxy (DimNameProxy const & other):
34
34
data_ (other.data_), dim_(other.dim_) {}
35
-
36
- inline DimNameProxy& operator = (SEXP other) {
35
+
36
+ inline DimNameProxy& assign (SEXP other) {
37
37
SEXP dims = Rf_getAttrib (data_, R_DimSymbol);
38
38
if (INTEGER (dims)[dim_] != Rf_length (other)) {
39
39
stop (" dimension extent is '%d' while length of names is '%d'" , INTEGER (dims)[dim_], Rf_length (other));
@@ -47,27 +47,16 @@ namespace internal{
47
47
SET_VECTOR_ELT (dimnames, dim_, other);
48
48
}
49
49
return *this ;
50
+ }
51
+
52
+ inline DimNameProxy& operator =(SEXP other) {
53
+ return assign (other);
50
54
}
51
55
52
56
inline DimNameProxy& operator =(const DimNameProxy& other) {
53
- SEXP dims = Rf_getAttrib (data_, R_DimSymbol);
54
- if (INTEGER (dims)[dim_] != INTEGER (dims)[other.dim_ ]) {
55
- stop (" dimension extent is '%d' while length of names is '%d'" , INTEGER (dims)[dim_], INTEGER (dims)[other.dim_ ]);
56
- }
57
- SEXP dimnames = Rf_getAttrib (data_, R_DimNamesSymbol);
58
- SEXP other_dimnames = SEXP (other);
59
- if (Rf_isNull (dimnames)) {
60
- Shield<SEXP> new_dimnames (Rf_allocVector (VECSXP, Rf_length (dims)));
61
- SET_VECTOR_ELT (new_dimnames, dim_, other_dimnames);
62
- Rf_setAttrib (data_, R_DimNamesSymbol, new_dimnames);
63
- } else {
64
- SET_VECTOR_ELT (dimnames, dim_, other_dimnames);
65
- }
66
- return *this ;
57
+ return assign (SEXP (other));
67
58
}
68
59
69
-
70
-
71
60
inline operator SEXP () const {
72
61
SEXP dimnames = Rf_getAttrib (data_, R_DimNamesSymbol);
73
62
return Rf_isNull (dimnames) ? (R_NilValue) : (VECTOR_ELT (dimnames, dim_));
0 commit comments