Skip to content

Commit 2dcfe6a

Browse files
committed
Try faster nbytes extraction for string types
1 parent cdfa0d7 commit 2dcfe6a

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

R/read_npy.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,13 @@ parse_npy_datatype <- function(descr) {
135135
return(
136136
list(
137137
base_type = "string",
138-
nbytes = as.integer(sub("|S", "", descr, fixed = TRUE)),
138+
nbytes = as.integer(substring(descr, 3L)),
139139
endian = NA_character_
140140
)
141141
)
142142
}
143143
if (startsWith(descr, "<U") || startsWith(descr, ">U")) {
144-
charlen <- as.integer(sub("^[<>]U", "", descr))
144+
charlen <- as.integer(substring(descr, 3L))
145145
return(
146146
list(
147147
base_type = "unicode",

0 commit comments

Comments
 (0)