Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
traversc committed Sep 8, 2024
1 parent c180c71 commit 96de7c9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions src/qd_deserializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,25 +262,25 @@ struct QdataDeserializer {
case qstype::LOGICAL:
object = PROTECT(Rf_allocVector(LGLSXP, object_length));
read_and_assign_attributes(object, attr_length);
integer_sexp.push_back(std::make_pair(object, object_length));
if(object_length > 0) integer_sexp.push_back(std::make_pair(object, object_length));
// reader.get_data( reinterpret_cast<char*>(LOGICAL(object)), object_length*4);
break;
case qstype::INTEGER:
object = PROTECT(Rf_allocVector(INTSXP, object_length));
read_and_assign_attributes(object, attr_length);
integer_sexp.push_back(std::make_pair(object, object_length));
if(object_length > 0) integer_sexp.push_back(std::make_pair(object, object_length));
// reader.get_data( reinterpret_cast<char*>(INTEGER(object)), object_length*4 );
break;
case qstype::REAL:
object = PROTECT(Rf_allocVector(REALSXP, object_length));
read_and_assign_attributes(object, attr_length);
real_sexp.push_back(std::make_pair(object, object_length));
if(object_length > 0) real_sexp.push_back(std::make_pair(object, object_length));
// reader.get_data( reinterpret_cast<char*>(REAL(object)), object_length*8 );
break;
case qstype::COMPLEX:
object = PROTECT(Rf_allocVector(CPLXSXP, object_length));
read_and_assign_attributes(object, attr_length);
complex_sexp.push_back(std::make_pair(object, object_length));
if(object_length > 0) complex_sexp.push_back(std::make_pair(object, object_length));
// reader.get_data( reinterpret_cast<char*>(COMPLEX(object)), object_length*16 );
break;
case qstype::CHARACTER:
Expand All @@ -291,7 +291,7 @@ struct QdataDeserializer {
object = PROTECT(Rf_allocVector(STRSXP, object_length));
}
read_and_assign_attributes(object, attr_length);
character_sexp.push_back(std::make_pair(object, object_length));
if(object_length > 0) character_sexp.push_back(std::make_pair(object, object_length));
break;
}
case qstype::LIST:
Expand All @@ -306,7 +306,7 @@ struct QdataDeserializer {
case qstype::RAW:
object = PROTECT(Rf_allocVector(RAWSXP, object_length));
read_and_assign_attributes(object, attr_length);
raw_sexp.push_back(std::make_pair(object, object_length));
if(object_length > 0) raw_sexp.push_back(std::make_pair(object, object_length));
// reader.get_data( reinterpret_cast<char*>(RAW(object)), object_length );
break;
default:
Expand Down
12 changes: 6 additions & 6 deletions src/qd_serializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ struct QdataSerializer {
std::vector< std::pair<SEXP, SEXP> > attrs = get_attributes(object);
write_header_lglsxp(object_length, attrs.size());
write_attributes(attrs);
integer_sexp.push_back(std::make_pair(object, object_length));
if(object_length > 0) integer_sexp.push_back(std::make_pair(object, object_length));
// writer.push_data(reinterpret_cast<char*>(LOGICAL(object)), object_length * 4);
return;
}
Expand All @@ -244,7 +244,7 @@ struct QdataSerializer {
std::vector< std::pair<SEXP, SEXP> > attrs = get_attributes(object);
write_header_intsxp(object_length, attrs.size());
write_attributes(attrs);
integer_sexp.push_back(std::make_pair(object, object_length));
if(object_length > 0) integer_sexp.push_back(std::make_pair(object, object_length));
// writer.push_data(reinterpret_cast<char*>(INTEGER(object)), object_length * 4);
return;
}
Expand All @@ -254,7 +254,7 @@ struct QdataSerializer {
std::vector< std::pair<SEXP, SEXP> > attrs = get_attributes(object);
write_header_realsxp(object_length, attrs.size());
write_attributes(attrs);
real_sexp.push_back(std::make_pair(object, object_length));
if(object_length > 0) real_sexp.push_back(std::make_pair(object, object_length));
// writer.push_data(reinterpret_cast<char*>(REAL(object)), object_length * 8);
return;
}
Expand All @@ -264,7 +264,7 @@ struct QdataSerializer {
std::vector< std::pair<SEXP, SEXP> > attrs = get_attributes(object);
write_header_cplxsxp(object_length, attrs.size());
write_attributes(attrs);
complex_sexp.push_back(std::make_pair(object, object_length));
if(object_length > 0) complex_sexp.push_back(std::make_pair(object, object_length));
// writer.push_data(reinterpret_cast<char*>(COMPLEX(object)), object_length * 16);
return;
}
Expand All @@ -274,7 +274,7 @@ struct QdataSerializer {
std::vector< std::pair<SEXP, SEXP> > attrs = get_attributes(object);
write_header_strsxp(object_length, attrs.size());
write_attributes(attrs);
character_sexp.push_back(std::make_pair(object, object_length));
if(object_length > 0) character_sexp.push_back(std::make_pair(object, object_length));
return;
}
case VECSXP:
Expand All @@ -295,7 +295,7 @@ struct QdataSerializer {
std::vector< std::pair<SEXP, SEXP> > attrs = get_attributes(object);
write_header_rawsxp(object_length, attrs.size());
write_attributes(attrs);
raw_sexp.push_back(std::make_pair(object, object_length));
if(object_length > 0) raw_sexp.push_back(std::make_pair(object, object_length));
// writer.push_data(reinterpret_cast<char*>(RAW(object)), object_length);
return;
}
Expand Down

0 comments on commit 96de7c9

Please sign in to comment.