aboutsummaryrefslogtreecommitdiff
path: root/src/fpm_filesystem.F90
diff options
context:
space:
mode:
authorCarlos Une <brocolis@eml.cc>2021-07-20 00:48:50 -0300
committerCarlos Une <brocolis@eml.cc>2021-07-20 00:48:50 -0300
commitbb0c412b4a331166c12f48b90dd0d5397da34e04 (patch)
tree6b7f0c29d66cecf99800608616fe3587f74e0bee /src/fpm_filesystem.F90
parent670e273ebb70c7be3615af4649112d75f043246b (diff)
downloadfpm-bb0c412b4a331166c12f48b90dd0d5397da34e04.tar.gz
fpm-bb0c412b4a331166c12f48b90dd0d5397da34e04.zip
Cache `filesep` in `join_path` using the save attribute
Diffstat (limited to 'src/fpm_filesystem.F90')
-rw-r--r--src/fpm_filesystem.F9022
1 files changed, 16 insertions, 6 deletions
diff --git a/src/fpm_filesystem.F90 b/src/fpm_filesystem.F90
index b589c24..a26af75 100644
--- a/src/fpm_filesystem.F90
+++ b/src/fpm_filesystem.F90
@@ -260,13 +260,23 @@ function join_path(a1,a2,a3,a4,a5) result(path)
character(len=*), intent(in), optional :: a3, a4, a5
character(len=:), allocatable :: path
character(len=1) :: filesep
+ logical, save :: has_cache = .false.
+ character(len=1), save :: cache = '/'
+ !$omp threadprivate(has_cache, cache)
- select case (get_os_type())
- case (OS_UNKNOWN, OS_LINUX, OS_MACOS, OS_CYGWIN, OS_SOLARIS, OS_FREEBSD, OS_OPENBSD)
- filesep = '/'
- case (OS_WINDOWS)
- filesep = '\'
- end select
+ if (has_cache) then
+ filesep = cache
+ else
+ select case (get_os_type())
+ case default
+ filesep = '/'
+ case (OS_WINDOWS)
+ filesep = '\'
+ end select
+
+ cache = filesep
+ has_cache = .true.
+ end if
path = a1 // filesep // a2