Skip to content

Commit bb0c412

Browse files
author
Carlos Une
committed
Cache filesep in join_path using the save attribute
1 parent 670e273 commit bb0c412

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/fpm_filesystem.F90

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -260,13 +260,23 @@ function join_path(a1,a2,a3,a4,a5) result(path)
260260
character(len=*), intent(in), optional :: a3, a4, a5
261261
character(len=:), allocatable :: path
262262
character(len=1) :: filesep
263+
logical, save :: has_cache = .false.
264+
character(len=1), save :: cache = '/'
265+
!$omp threadprivate(has_cache, cache)
263266

264-
select case (get_os_type())
265-
case (OS_UNKNOWN, OS_LINUX, OS_MACOS, OS_CYGWIN, OS_SOLARIS, OS_FREEBSD, OS_OPENBSD)
266-
filesep = '/'
267-
case (OS_WINDOWS)
268-
filesep = '\'
269-
end select
267+
if (has_cache) then
268+
filesep = cache
269+
else
270+
select case (get_os_type())
271+
case default
272+
filesep = '/'
273+
case (OS_WINDOWS)
274+
filesep = '\'
275+
end select
276+
277+
cache = filesep
278+
has_cache = .true.
279+
end if
270280

271281
path = a1 // filesep // a2
272282

0 commit comments

Comments
 (0)