Skip to content

Commit

Permalink
Now serializedSize() always returns a double [#123]
Browse files Browse the repository at this point in the history
  • Loading branch information
HenrikBengtsson committed Dec 15, 2024
1 parent 88783a6 commit 3b8fa4f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: parallelly
Version: 1.40.1-9006
Version: 1.40.1-9007
Title: Enhancing the 'parallel' Package
Imports:
parallel,
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
* `makeClusterPSOCK()` will now produce an error, rather than a
warning, when the local system command used to launch the parallel
worker failed with a non-zero exit code.

* Now `serializedSize()` always returns a double. Previously, it
would return an integer, if the value could be represented by an
integer. However, it turned out that returning an integer increased
the risk for integer overflow later on if, say, to such values were
added together.

## Bug Fixes

Expand Down
2 changes: 1 addition & 1 deletion R/serializedSize.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#'
#' @param obj An R object.
#'
#' @return (integer or double) Number of bytes needed to serialize this object.
#' @return (double) Number of bytes needed to serialize this object.
#'
#' @examples
#' object.size(mtcars)
Expand Down
2 changes: 1 addition & 1 deletion man/serializedSize.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 1 addition & 5 deletions src/calc-serialized-size.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,5 @@ R_xlen_t calc_serialized_size(SEXP robj) {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SEXP R_calc_serialized_size(SEXP robj) {
R_xlen_t count = calc_serialized_size(robj);
if (count > R_INT_MAX) {
return(ScalarReal((double) count));
} else {
return(ScalarInteger(count));
}
return(ScalarReal((double) count));
}

0 comments on commit 3b8fa4f

Please sign in to comment.