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
b833c5d2
Commit
b833c5d2
authored
Jan 14, 2021
by
Max Kellermann
Committed by
Max Kellermann
Mar 04, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
util/AllocatedString: replace Clone() with copy constructor
parent
bca5d79f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
10 deletions
+9
-10
Compare.hxx
src/lib/icu/Compare.hxx
+5
-5
AllocatedString.hxx
src/util/AllocatedString.hxx
+4
-5
No files found.
src/lib/icu/Compare.hxx
View file @
b833c5d2
...
...
@@ -38,11 +38,11 @@ class IcuCompare {
#ifdef _WIN32
/* Windows API functions work with wchar_t strings, so let's
cache the MultiByteToWideChar() result for performance */
BasicAllocatedString
<
wchar_t
>
needle
;
#else
AllocatedString
needle
;
using
AllocatedString
=
BasicAllocatedString
<
wchar_t
>
;
#endif
AllocatedString
needle
;
public
:
IcuCompare
()
:
needle
(
nullptr
)
{}
...
...
@@ -50,12 +50,12 @@ public:
IcuCompare
(
const
IcuCompare
&
src
)
noexcept
:
needle
(
src
?
src
.
needle
.
Clone
(
)
?
AllocatedString
(
src
.
needle
)
:
nullptr
)
{}
IcuCompare
&
operator
=
(
const
IcuCompare
&
src
)
noexcept
{
needle
=
src
?
src
.
needle
.
Clone
(
)
?
AllocatedString
(
src
.
needle
)
:
nullptr
;
return
*
this
;
}
...
...
src/util/AllocatedString.hxx
View file @
b833c5d2
...
...
@@ -71,6 +71,9 @@ public:
explicit
BasicAllocatedString
(
const_pointer
src
)
:
value
(
Duplicate
(
src
))
{}
BasicAllocatedString
(
const
BasicAllocatedString
&
src
)
noexcept
:
BasicAllocatedString
(
Duplicate
(
src
.
value
))
{}
BasicAllocatedString
(
BasicAllocatedString
&&
src
)
noexcept
:
value
(
src
.
Steal
())
{}
...
...
@@ -137,10 +140,6 @@ public:
return
std
::
exchange
(
value
,
nullptr
);
}
BasicAllocatedString
Clone
()
const
{
return
BasicAllocatedString
(
Duplicate
(
*
this
));
}
private
:
static
pointer
Duplicate
(
string_view
src
)
{
auto
p
=
new
value_type
[
src
.
size
()
+
1
];
...
...
@@ -150,7 +149,7 @@ private:
static
pointer
Duplicate
(
const_pointer
src
)
{
return
src
!=
nullptr
?
Duplicate
(
st
d
::
st
ring_view
(
src
))
?
Duplicate
(
string_view
(
src
))
:
nullptr
;
}
};
...
...
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