Skip to content

Commit e59fef9

Browse files
derekmauroliujinye-sys
authored andcommitted
Stop moving an absl::FunctionRef, since the class isn't movable, it
will just be a copy anyway. Also remove the typedef so that it is clear from the type at the callsite that moving it isn't necessary. Fixes #1443 PiperOrigin-RevId: 530596294 Change-Id: I58ffc370bbccc0816bca4c4f85c3bb12c7ee2eb2
1 parent c9d48ce commit e59fef9

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

absl/strings/internal/cord_rep_consume.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ CordRep* ClipSubstring(CordRepSubstring* substring) {
4242

4343
} // namespace
4444

45-
void Consume(CordRep* rep, ConsumeFn consume_fn) {
45+
void Consume(CordRep* rep,
46+
FunctionRef<void(CordRep*, size_t, size_t)> consume_fn) {
4647
size_t offset = 0;
4748
size_t length = rep->length;
4849

@@ -53,8 +54,9 @@ void Consume(CordRep* rep, ConsumeFn consume_fn) {
5354
consume_fn(rep, offset, length);
5455
}
5556

56-
void ReverseConsume(CordRep* rep, ConsumeFn consume_fn) {
57-
return Consume(rep, std::move(consume_fn));
57+
void ReverseConsume(CordRep* rep,
58+
FunctionRef<void(CordRep*, size_t, size_t)> consume_fn) {
59+
return Consume(rep, consume_fn);
5860
}
5961

6062
} // namespace cord_internal

absl/strings/internal/cord_rep_consume.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ namespace absl {
2424
ABSL_NAMESPACE_BEGIN
2525
namespace cord_internal {
2626

27-
// Functor for the Consume() and ReverseConsume() functions:
28-
// void ConsumeFunc(CordRep* rep, size_t offset, size_t length);
29-
// See the Consume() and ReverseConsume() function comments for documentation.
30-
using ConsumeFn = FunctionRef<void(CordRep*, size_t, size_t)>;
31-
3227
// Consume() and ReverseConsume() consume CONCAT based trees and invoke the
3328
// provided functor with the contained nodes in the proper forward or reverse
3429
// order, which is used to convert CONCAT trees into other tree or cord data.
@@ -40,8 +35,10 @@ using ConsumeFn = FunctionRef<void(CordRep*, size_t, size_t)>;
4035
// violations, we can not 100% guarantee that all code respects 'new format'
4136
// settings and flags, so we need to be able to parse old data on the fly until
4237
// all old code is deprecated / no longer the default format.
43-
void Consume(CordRep* rep, ConsumeFn consume_fn);
44-
void ReverseConsume(CordRep* rep, ConsumeFn consume_fn);
38+
void Consume(CordRep* rep,
39+
FunctionRef<void(CordRep*, size_t, size_t)> consume_fn);
40+
void ReverseConsume(CordRep* rep,
41+
FunctionRef<void(CordRep*, size_t, size_t)> consume_fn);
4542

4643
} // namespace cord_internal
4744
ABSL_NAMESPACE_END

0 commit comments

Comments
 (0)