Skip to content

Commit 054166e

Browse files
authored
Merge pull request #2191 from MichaelChirico/startswith
Use startsWith() over substr()
2 parents dce482b + a8515c3 commit 054166e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

R/proj.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ sf_proj_pipelines = function(source_crs, target_crs, authority = character(0), A
150150
as.numeric(desired_accuracy), as.logical(strict_containment),
151151
as.logical(axis_order_authority_compliant))
152152
if (nrow(ret)) {
153-
if (substr(ret$definition[1], 1, 1) != "+") # paste + to every word
153+
if (!startsWith(ret$definition[1], "+")) # paste + to every word
154154
ret$definition =
155155
sapply(strsplit(ret$definition, " "),
156156
function(x) paste0(paste0("+", x), collapse=" "))

R/wkb.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#
77
hex_to_raw = function(y) {
88
stopifnot((nchar(y) %% 2) == 0)
9-
if (substr(y, 1, 2) == "0x")
9+
if (startsWith(y, "0x"))
1010
y = substr(y, 3, nchar(y))
1111
as.raw(as.numeric(paste0("0x", vapply(seq_len(nchar(y)/2),
1212
function(x) substr(y, (x-1)*2+1, x*2), "")))) # SLOW, hence the Rcpp implementation
@@ -15,7 +15,7 @@ hex_to_raw = function(y) {
1515
skip0x = function(x) {
1616
if (is.na(x))
1717
"010700000000000000" # empty GeometryCollection, st_as_binary(st_geometrycollection())
18-
else if (substr(x, 1, 2) == "0x")
18+
else if (startsWith(x, "0x"))
1919
substr(x, 3, nchar(x))
2020
else
2121
x

0 commit comments

Comments
 (0)