Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
a885bdba
Commit
a885bdba
authored
5 years ago
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fs/Traits: pass string_view to Build()
parent
b6b15afb
sisyphus
0.23.15-alt1
0.23.14-alt1
0.23.13-alt1
0.23.12-alt1
0.23.11-alt1
0.23.8-alt3
0.23.8-alt2
0.23.8-alt1
gb-sisyphus-task339776.6100
gb-sisyphus-task337393.100
gb-sisyphus-task337176.300
gb-sisyphus-task334590.100
gb-sisyphus-task333607.100
gb-sisyphus-task331543.2500
gb-sisyphus-task328663.4700
gb-sisyphus-task325064.100
gb-sisyphus-task319111.4000
gb-sisyphus-task313704.100
gb-sisyphus-task312885.100
gb-sisyphus-task308905.3200
gb-sisyphus-task305294.500
gb-sisyphus-task304007.100
gb-sisyphus-task303674.1700
No related merge requests found
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
54 deletions
+29
-54
AllocatedPath.hxx
src/fs/AllocatedPath.hxx
+9
-17
Traits.cxx
src/fs/Traits.cxx
+16
-21
Traits.hxx
src/fs/Traits.hxx
+4
-16
No files found.
src/fs/AllocatedPath.hxx
View file @
a885bdba
...
...
@@ -56,10 +56,6 @@ class AllocatedPath {
AllocatedPath
(
string
&&
_value
)
noexcept
:
value
(
std
::
move
(
_value
))
{}
static
AllocatedPath
Build
(
const_pointer
a
,
size_t
a_size
,
const_pointer
b
,
size_t
b_size
)
noexcept
{
return
AllocatedPath
(
Traits
::
Build
(
a
,
a_size
,
b
,
b_size
));
}
public
:
/**
* Construct a "nulled" instance. Its IsNull() method will
...
...
@@ -93,14 +89,13 @@ public:
/**
* Join two path components with the path separator.
*/
gcc_pure
gcc_nonnull_all
static
AllocatedPath
Build
(
const_pointer
a
,
const_pointer
b
)
noexcept
{
return
Build
(
a
,
Traits
::
GetLength
(
a
),
b
,
Traits
::
GetLength
(
b
));
gcc_pure
static
AllocatedPath
Build
(
string_view
a
,
string_view
b
)
noexcept
{
return
AllocatedPath
(
Traits
::
Build
(
a
,
b
));
}
gcc_pure
gcc_nonnull_all
static
AllocatedPath
Build
(
Path
a
,
const_pointer
b
)
noexcept
{
static
AllocatedPath
Build
(
Path
a
,
string_view
b
)
noexcept
{
return
Build
(
a
.
c_str
(),
b
);
}
...
...
@@ -110,24 +105,21 @@ public:
}
gcc_pure
gcc_nonnull_all
static
AllocatedPath
Build
(
const_pointer
a
,
static
AllocatedPath
Build
(
string_view
a
,
const
AllocatedPath
&
b
)
noexcept
{
return
Build
(
a
,
Traits
::
GetLength
(
a
),
b
.
value
.
c_str
(),
b
.
value
.
size
());
return
Build
(
a
,
b
.
value
);
}
gcc_pure
gcc_nonnull_all
static
AllocatedPath
Build
(
const
AllocatedPath
&
a
,
const_pointer
b
)
noexcept
{
return
Build
(
a
.
value
.
c_str
(),
a
.
value
.
size
(),
b
,
Traits
::
GetLength
(
b
));
string_view
b
)
noexcept
{
return
Build
(
a
.
value
,
b
);
}
gcc_pure
static
AllocatedPath
Build
(
const
AllocatedPath
&
a
,
const
AllocatedPath
&
b
)
noexcept
{
return
Build
(
a
.
value
.
c_str
(),
a
.
value
.
size
(),
b
.
value
.
c_str
(),
b
.
value
.
size
());
return
Build
(
a
.
value
,
b
.
value
);
}
gcc_pure
...
...
This diff is collapsed.
Click to expand it.
src/fs/Traits.cxx
View file @
a885bdba
...
...
@@ -24,29 +24,26 @@
template
<
typename
Traits
>
typename
Traits
::
string
BuildPathImpl
(
typename
Traits
::
const_pointer
a
,
size_t
a_size
,
typename
Traits
::
const_pointer
b
,
size_t
b_size
)
noexcept
BuildPathImpl
(
typename
Traits
::
string_view
a
,
typename
Traits
::
string_view
b
)
noexcept
{
assert
(
a
!=
nullptr
);
assert
(
b
!=
nullptr
);
if
(
a_size
==
0
)
return
typename
Traits
::
string
(
b
,
b_size
);
if
(
b_size
==
0
)
return
typename
Traits
::
string
(
a
,
a_size
);
if
(
a
.
empty
())
return
typename
Traits
::
string
(
b
);
if
(
b
.
empty
())
return
typename
Traits
::
string
(
a
);
typename
Traits
::
string
result
;
result
.
reserve
(
a
_size
+
1
+
b_size
);
result
.
reserve
(
a
.
length
()
+
1
+
b
.
length
()
);
result
.
append
(
a
,
a_size
);
result
.
append
(
a
);
if
(
!
Traits
::
IsSeparator
(
a
[
a_size
-
1
]
))
if
(
!
Traits
::
IsSeparator
(
a
.
back
()
))
result
.
push_back
(
Traits
::
SEPARATOR
);
if
(
Traits
::
IsSeparator
(
b
[
0
]
))
result
.
append
(
b
+
1
,
b_size
-
1
);
if
(
Traits
::
IsSeparator
(
b
.
front
()
))
result
.
append
(
b
.
substr
(
1
)
);
else
result
.
append
(
b
,
b_size
);
result
.
append
(
b
);
return
result
;
}
...
...
@@ -122,10 +119,9 @@ RelativePathImpl(typename Traits::const_pointer base,
}
PathTraitsFS
::
string
PathTraitsFS
::
Build
(
const_pointer
a
,
size_t
a_size
,
const_pointer
b
,
size_t
b_size
)
noexcept
PathTraitsFS
::
Build
(
string_view
a
,
string_view
b
)
noexcept
{
return
BuildPathImpl
<
PathTraitsFS
>
(
a
,
a_size
,
b
,
b_size
);
return
BuildPathImpl
<
PathTraitsFS
>
(
a
,
b
);
}
PathTraitsFS
::
const_pointer
...
...
@@ -161,10 +157,9 @@ PathTraitsFS::Apply(const_pointer base, const_pointer path) noexcept
}
PathTraitsUTF8
::
string
PathTraitsUTF8
::
Build
(
const_pointer
a
,
size_t
a_size
,
const_pointer
b
,
size_t
b_size
)
noexcept
PathTraitsUTF8
::
Build
(
string_view
a
,
string_view
b
)
noexcept
{
return
BuildPathImpl
<
PathTraitsUTF8
>
(
a
,
a_size
,
b
,
b_size
);
return
BuildPathImpl
<
PathTraitsUTF8
>
(
a
,
b
);
}
PathTraitsUTF8
::
const_pointer
...
...
This diff is collapsed.
Click to expand it.
src/fs/Traits.hxx
View file @
a885bdba
...
...
@@ -156,14 +156,8 @@ struct PathTraitsFS {
* remaining component is returned unchanged.
* If both components are empty strings, empty string is returned.
*/
gcc_pure
gcc_nonnull_all
static
string
Build
(
const_pointer
a
,
size_t
a_size
,
const_pointer
b
,
size_t
b_size
)
noexcept
;
gcc_pure
gcc_nonnull_all
static
string
Build
(
const_pointer
a
,
const_pointer
b
)
noexcept
{
return
Build
(
a
,
GetLength
(
a
),
b
,
GetLength
(
b
));
}
gcc_pure
static
string
Build
(
string_view
a
,
string_view
b
)
noexcept
;
/**
* Interpret the given path as being relative to the given
...
...
@@ -271,14 +265,8 @@ struct PathTraitsUTF8 {
* remaining component is returned unchanged.
* If both components are empty strings, empty string is returned.
*/
gcc_pure
gcc_nonnull_all
static
string
Build
(
const_pointer
a
,
size_t
a_size
,
const_pointer
b
,
size_t
b_size
)
noexcept
;
gcc_pure
gcc_nonnull_all
static
string
Build
(
const_pointer
a
,
const_pointer
b
)
noexcept
{
return
Build
(
a
,
GetLength
(
a
),
b
,
GetLength
(
b
));
}
gcc_pure
static
string
Build
(
string_view
a
,
string_view
b
)
noexcept
;
};
#endif
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment