Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
abseil-cpp
Overview
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
abseil-cpp
Commits
a26fc02d
Commit
a26fc02d
authored
Mar 16, 2023
by
Rose
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prefer copy_n and fill_n over copy and fill where appropriate.
This lets us avoid having to do the addition manually.
parent
e85868cb
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
11 additions
and
10 deletions
+11
-10
absl/random/internal/nanobenchmark.cc
+1
-1
absl/strings/escaping.cc
+3
-2
absl/strings/internal/charconv_bigint.cc
+2
-2
absl/strings/internal/charconv_bigint.h
+2
-2
absl/synchronization/internal/graphcycles.cc
+2
-2
absl/time/internal/cctz/src/time_zone_fixed.cc
+1
-1
No files found.
absl/random/internal/nanobenchmark.cc
View file @
a26fc02d
...
...
@@ -361,7 +361,7 @@ void CountingSort(T* values, size_t num_values) {
// Write that many copies of each unique value to the array.
T
*
ABSL_RANDOM_INTERNAL_RESTRICT
p
=
values
;
for
(
const
auto
&
value_count
:
unique
)
{
std
::
fill
(
p
,
p
+
value_count
.
second
,
value_count
.
first
);
std
::
fill
_n
(
p
,
value_count
.
second
,
value_count
.
first
);
p
+=
value_count
.
second
;
}
ABSL_RAW_CHECK
(
p
==
values
+
num_values
,
"Did not produce enough output"
);
...
...
absl/strings/escaping.cc
View file @
a26fc02d
...
...
@@ -846,9 +846,10 @@ void HexStringToBytesInternal(const char* from, T to, size_t num) {
template
<
typename
T
>
void
BytesToHexStringInternal
(
const
unsigned
char
*
src
,
T
dest
,
size_t
num
)
{
auto
dest_ptr
=
&
dest
[
0
];
for
(
auto
src_ptr
=
src
;
src_ptr
!=
(
src
+
num
);
++
src_ptr
,
dest_ptr
+=
2
)
{
for
(
auto
src_ptr
=
src
;
src_ptr
!=
(
src
+
num
);
++
src_ptr
)
{
const
char
*
hex_p
=
&
numbers_internal
::
kHexTable
[
*
src_ptr
*
2
];
std
::
copy
(
hex_p
,
hex_p
+
2
,
dest_ptr
);
*
dest_ptr
++
=
*
hex_p
++
;
*
dest_ptr
++
=
*
hex_p
;
}
}
...
...
absl/strings/internal/charconv_bigint.cc
View file @
a26fc02d
...
...
@@ -296,9 +296,9 @@ template <int max_words>
std
::
min
(
n
/
kLargePowerOfFiveStep
,
kLargestPowerOfFiveIndex
);
if
(
first_pass
)
{
// just copy, rather than multiplying by 1
std
::
copy
(
std
::
copy
_n
(
LargePowerOfFiveData
(
big_power
),
LargePowerOfFive
Data
(
big_power
)
+
LargePowerOfFive
Size
(
big_power
),
LargePowerOfFiveSize
(
big_power
),
answer
.
words_
);
answer
.
size_
=
LargePowerOfFiveSize
(
big_power
);
first_pass
=
false
;
...
...
absl/strings/internal/charconv_bigint.h
View file @
a26fc02d
...
...
@@ -121,7 +121,7 @@ class BigUnsigned {
++
size_
;
}
}
std
::
fill
(
words_
,
words_
+
word_shift
,
0u
);
std
::
fill
_n
(
words_
,
word_shift
,
0u
);
}
}
...
...
@@ -197,7 +197,7 @@ class BigUnsigned {
}
void
SetToZero
()
{
std
::
fill
(
words_
,
words_
+
size_
,
0u
);
std
::
fill
_n
(
words_
,
size_
,
0u
);
size_
=
0
;
}
...
...
absl/synchronization/internal/graphcycles.cc
View file @
a26fc02d
...
...
@@ -114,7 +114,7 @@ class Vec {
if
(
src
->
ptr_
==
src
->
space_
)
{
// Need to actually copy
resize
(
src
->
size_
);
std
::
copy
(
src
->
ptr_
,
src
->
ptr_
+
src
->
size_
,
ptr_
);
std
::
copy
_n
(
src
->
ptr_
,
src
->
size_
,
ptr_
);
src
->
size_
=
0
;
}
else
{
Discard
();
...
...
@@ -148,7 +148,7 @@ class Vec {
size_t
request
=
static_cast
<
size_t
>
(
capacity_
)
*
sizeof
(
T
);
T
*
copy
=
static_cast
<
T
*>
(
base_internal
::
LowLevelAlloc
::
AllocWithArena
(
request
,
arena
));
std
::
copy
(
ptr_
,
ptr_
+
size_
,
copy
);
std
::
copy
_n
(
ptr_
,
size_
,
copy
);
Discard
();
ptr_
=
copy
;
}
...
...
absl/time/internal/cctz/src/time_zone_fixed.cc
View file @
a26fc02d
...
...
@@ -105,7 +105,7 @@ std::string FixedOffsetToName(const seconds& offset) {
offset_minutes
%=
60
;
const
std
::
size_t
prefix_len
=
sizeof
(
kFixedZonePrefix
)
-
1
;
char
buf
[
prefix_len
+
sizeof
(
"-24:00:00"
)];
char
*
ep
=
std
::
copy
(
kFixedZonePrefix
,
kFixedZonePrefix
+
prefix_len
,
buf
);
char
*
ep
=
std
::
copy
_n
(
kFixedZonePrefix
,
prefix_len
,
buf
);
*
ep
++
=
sign
;
ep
=
Format02d
(
ep
,
offset_hours
);
*
ep
++
=
':'
;
...
...
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