Skip to content

Commit

Permalink
perf: Patch URI parsing library
Browse files Browse the repository at this point in the history
  • Loading branch information
slavek-kucera authored Feb 10, 2023
1 parent 0bd9a96 commit 741ef11
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmake/apply_patch.cmake → cmake/apply_antlr_patch.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# The patch step of ExternalProject_Add is executed repeatedly even when there
# is no change to CmakeLists or the external project

set(PATCH_STAMP "${CMAKE_BINARY_DIR}/patch_applied.stamp")
set(PATCH_STAMP "${CMAKE_BINARY_DIR}/antlr_patch_applied.stamp")

if(NOT EXISTS ${PATCH_STAMP})
execute_process(COMMAND ${GIT_EXECUTABLE} apply ${PROJECT_SOURCE_DIR}/cmake/antlr_patch.diff)
Expand Down
18 changes: 18 additions & 0 deletions cmake/apply_uri_patch.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright (c) 2023 Broadcom.
# The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
#
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Broadcom, Inc. - initial API and implementation

set(PATCH_STAMP "${CMAKE_BINARY_DIR}/uri_patch_applied.stamp")

if(NOT EXISTS ${PATCH_STAMP})
execute_process(COMMAND ${GIT_EXECUTABLE} apply ${PROJECT_SOURCE_DIR}/cmake/uri_patch.diff)
execute_process(COMMAND ${CMAKE_COMMAND} -E touch ${PATCH_STAMP})
endif()
2 changes: 1 addition & 1 deletion cmake/external_antlr4cpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ FetchContent_Declare(
GIT_SHALLOW ON
LOG_DOWNLOAD ON
GIT_PROGRESS 1
PATCH_COMMAND ${CMAKE_COMMAND} -DGIT_EXECUTABLE=${GIT_EXECUTABLE} -DPROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR} -DCMAKE_BINARY_DIR=${CMAKE_BINARY_DIR} -P ${PROJECT_SOURCE_DIR}/cmake/apply_patch.cmake
PATCH_COMMAND ${CMAKE_COMMAND} -DGIT_EXECUTABLE=${GIT_EXECUTABLE} -DPROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR} -DCMAKE_BINARY_DIR=${CMAKE_BINARY_DIR} -P ${PROJECT_SOURCE_DIR}/cmake/apply_antlr_patch.cmake
)

FetchContent_GetProperties(antlr4cpp)
Expand Down
1 change: 1 addition & 0 deletions cmake/external_uri.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ FetchContent_Declare(
GIT_SHALLOW ON
LOG_DOWNLOAD ON
GIT_PROGRESS 1
PATCH_COMMAND ${CMAKE_COMMAND} -DGIT_EXECUTABLE=${GIT_EXECUTABLE} -DPROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR} -DCMAKE_BINARY_DIR=${CMAKE_BINARY_DIR} -P ${PROJECT_SOURCE_DIR}/cmake/apply_uri_patch.cmake
)

FetchContent_GetProperties(uri_ext)
Expand Down
13 changes: 13 additions & 0 deletions cmake/uri_patch.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/src/detail/uri_parse.cpp b/src/detail/uri_parse.cpp
index 7f77148..73f581e 100644
--- a/src/detail/uri_parse.cpp
+++ b/src/detail/uri_parse.cpp
@@ -31,7 +31,7 @@ bool validate_scheme(string_view::const_iterator &it,
}

// The first character must be a letter
- if (!std::isalpha(*it, std::locale("C"))) {
+ if (!std::isalpha(*it, std::locale::classic())) {
return false;
}
++it;

0 comments on commit 741ef11

Please sign in to comment.