Skip to content

Commit

Permalink
Move errormode check (#219)
Browse files Browse the repository at this point in the history
* reduce R overhead for non-errors

* change log entry
  • Loading branch information
pearsonca authored Aug 28, 2024
1 parent fd1fa9f commit c73a5b5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2024-08-28 Carl A. B. Pearson <[email protected]>

* R/digest.R (digest): parse errormode only if in error conditions
* R/vdigest.R (getVDigest): parse errormode only if in error conditions

2024-08-24 Dirk Eddelbuettel <[email protected]>

* src/digest.c (digest): Remove unused variables
Expand Down
6 changes: 3 additions & 3 deletions R/digest.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ digest <- function(object, algo=c("md5", "sha1", "crc32", "sha256", "sha512",
"xxhash32", "xxhash64", "murmur32",
"spookyhash", "blake3", "crc32c",
"xxh3_64", "xxh3_128"))
errormode <- match.arg(errormode, c("stop", "warn", "silent"))

if (is.infinite(length)) {
length <- -1 # internally we use -1 for infinite len
Expand All @@ -57,8 +56,8 @@ digest <- function(object, algo=c("md5", "sha1", "crc32", "sha256", "sha512",
is_streaming_algo <- algo == "spookyhash"

if (is_streaming_algo && !serialize) {
.errorhandler(paste0(algo, " algorithm is not available without serialization."), # #nocov
mode=errormode) # #nocov
return(.errorhandler(paste0(algo, " algorithm is not available without serialization."), # #nocov
mode=errormode)) # #nocov
}

if (serialize && !file) {
Expand Down Expand Up @@ -129,6 +128,7 @@ digest <- function(object, algo=c("md5", "sha1", "crc32", "sha256", "sha512",
## utility functions used by digest() and getVDigest() below

.errorhandler <- function(txt, obj="", mode="stop") {
mode <- match.arg(mode, c("stop","warn","silent"))
if (mode == "stop") { # nocov start
stop(txt, obj, call.=FALSE)
} else if (mode == "warn") {
Expand Down
2 changes: 1 addition & 1 deletion R/vdigest.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ getVDigest <- function(algo = c("md5", "sha1", "crc32", "sha256", "sha512",
algo <- match.arg(algo, c("md5", "sha1", "crc32", "sha256", "sha512",
"xxhash32", "xxhash64", "murmur32", "spookyhash",
"blake3", "crc32c", "xxh3_64", "xxh3_128"))
errormode <- match.arg(errormode, c("stop","warn","silent"))

algoint <- algo_int(algo)
non_streaming_algos <- c("md5", "sha1", "crc32", "sha256", "sha512",
"xxhash32", "xxhash64", "murmur32", "blake3",
Expand Down

0 comments on commit c73a5b5

Please sign in to comment.