From 67526c25f4a751be27d2f9eed38d07fe52342aa5 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 10 May 2023 16:00:29 -0400 Subject: Add ZIX_STATIC_STRING() --- src/path.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/path.c b/src/path.c index 385e6a8..8df04e6 100644 --- a/src/path.c +++ b/src/path.c @@ -496,6 +496,8 @@ zix_path_lexically_relative(ZixAllocator* const allocator, const char* const path, const char* const base) { + static const ZixStringView dot = ZIX_STATIC_STRING("."); + // Mismatched roots can't be expressed in relative form const ZixRootSlices path_root = zix_path_root_slices(path); const ZixRootSlices base_root = zix_path_root_slices(base); @@ -520,7 +522,7 @@ zix_path_lexically_relative(ZixAllocator* const allocator, // Matching paths reduce to "." if ((a.state == ZIX_PATH_END && b.state == ZIX_PATH_END) || (zix_is_empty_range(a.range) && b.state == ZIX_PATH_END)) { - return zix_string_view_copy(allocator, zix_string(".")); + return zix_string_view_copy(allocator, dot); } // Count the trailing non-matching entries in base @@ -546,7 +548,7 @@ zix_path_lexically_relative(ZixAllocator* const allocator, // A result with no up-references or names reduces to "." if (n_up == 0 && a.state == ZIX_PATH_END) { - return zix_string_view_copy(allocator, zix_string(".")); + return zix_string_view_copy(allocator, dot); } // Allocate buffer for relative path result -- cgit v1.2.1