Commit b19ec98a by Derek Mauro Committed by Copybara-Service

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
parent 41aecd02
......@@ -42,7 +42,8 @@ CordRep* ClipSubstring(CordRepSubstring* substring) {
} // namespace
void Consume(CordRep* rep, ConsumeFn consume_fn) {
void Consume(CordRep* rep,
FunctionRef<void(CordRep*, size_t, size_t)> consume_fn) {
size_t offset = 0;
size_t length = rep->length;
......@@ -53,8 +54,9 @@ void Consume(CordRep* rep, ConsumeFn consume_fn) {
consume_fn(rep, offset, length);
}
void ReverseConsume(CordRep* rep, ConsumeFn consume_fn) {
return Consume(rep, std::move(consume_fn));
void ReverseConsume(CordRep* rep,
FunctionRef<void(CordRep*, size_t, size_t)> consume_fn) {
return Consume(rep, consume_fn);
}
} // namespace cord_internal
......
......@@ -24,11 +24,6 @@ namespace absl {
ABSL_NAMESPACE_BEGIN
namespace cord_internal {
// Functor for the Consume() and ReverseConsume() functions:
// void ConsumeFunc(CordRep* rep, size_t offset, size_t length);
// See the Consume() and ReverseConsume() function comments for documentation.
using ConsumeFn = FunctionRef<void(CordRep*, size_t, size_t)>;
// Consume() and ReverseConsume() consume CONCAT based trees and invoke the
// provided functor with the contained nodes in the proper forward or reverse
// 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)>;
// violations, we can not 100% guarantee that all code respects 'new format'
// settings and flags, so we need to be able to parse old data on the fly until
// all old code is deprecated / no longer the default format.
void Consume(CordRep* rep, ConsumeFn consume_fn);
void ReverseConsume(CordRep* rep, ConsumeFn consume_fn);
void Consume(CordRep* rep,
FunctionRef<void(CordRep*, size_t, size_t)> consume_fn);
void ReverseConsume(CordRep* rep,
FunctionRef<void(CordRep*, size_t, size_t)> consume_fn);
} // namespace cord_internal
ABSL_NAMESPACE_END
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment