Make BitrateProber::IsProbing() inline.
Trivial perf optimization.
Bug: None
Change-Id: I0ceabc2a6aa0c52f4626c8792c17a60d2028712d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/171694
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30901}
diff --git a/modules/pacing/bitrate_prober.cc b/modules/pacing/bitrate_prober.cc
index e4ac7dd..e7ce01d9 100644
--- a/modules/pacing/bitrate_prober.cc
+++ b/modules/pacing/bitrate_prober.cc
@@ -74,10 +74,6 @@
}
}
-bool BitrateProber::IsProbing() const {
- return probing_state_ == ProbingState::kActive;
-}
-
void BitrateProber::OnIncomingPacket(size_t packet_size) {
// Don't initialize probing unless we have something large enough to start
// probing.
diff --git a/modules/pacing/bitrate_prober.h b/modules/pacing/bitrate_prober.h
index ec234e8..3ebe26a 100644
--- a/modules/pacing/bitrate_prober.h
+++ b/modules/pacing/bitrate_prober.h
@@ -52,7 +52,7 @@
// Returns true if the prober is in a probing session, i.e., it currently
// wants packets to be sent out according to the time returned by
// TimeUntilNextProbe().
- bool IsProbing() const;
+ bool is_probing() const { return probing_state_ == ProbingState::kActive; }
// Initializes a new probing session if the prober is allowed to probe. Does
// not initialize the prober unless the packet size is large enough to probe
diff --git a/modules/pacing/bitrate_prober_unittest.cc b/modules/pacing/bitrate_prober_unittest.cc
index 2d10c04..62277a0 100644
--- a/modules/pacing/bitrate_prober_unittest.cc
+++ b/modules/pacing/bitrate_prober_unittest.cc
@@ -19,7 +19,7 @@
TEST(BitrateProberTest, VerifyStatesAndTimeBetweenProbes) {
const FieldTrialBasedConfig config;
BitrateProber prober(config);
- EXPECT_FALSE(prober.IsProbing());
+ EXPECT_FALSE(prober.is_probing());
Timestamp now = Timestamp::Millis(0);
const Timestamp start_time = now;
@@ -33,10 +33,10 @@
prober.CreateProbeCluster(kTestBitrate1, now, 0);
prober.CreateProbeCluster(kTestBitrate2, now, 1);
- EXPECT_FALSE(prober.IsProbing());
+ EXPECT_FALSE(prober.is_probing());
prober.OnIncomingPacket(kProbeSize);
- EXPECT_TRUE(prober.IsProbing());
+ EXPECT_TRUE(prober.is_probing());
EXPECT_EQ(0, prober.CurrentCluster().probe_cluster_id);
// First packet should probe as soon as possible.
@@ -74,7 +74,7 @@
EXPECT_LT(bitrate, kTestBitrate2 * 1.1);
EXPECT_EQ(prober.NextProbeTime(now), Timestamp::PlusInfinity());
- EXPECT_FALSE(prober.IsProbing());
+ EXPECT_FALSE(prober.is_probing());
}
TEST(BitrateProberTest, DoesntProbeWithoutRecentPackets) {
@@ -85,10 +85,10 @@
EXPECT_EQ(prober.NextProbeTime(now), Timestamp::PlusInfinity());
prober.CreateProbeCluster(DataRate::KilobitsPerSec(900), now, 0);
- EXPECT_FALSE(prober.IsProbing());
+ EXPECT_FALSE(prober.is_probing());
prober.OnIncomingPacket(1000);
- EXPECT_TRUE(prober.IsProbing());
+ EXPECT_TRUE(prober.is_probing());
EXPECT_EQ(now, std::max(now, prober.NextProbeTime(now)));
prober.ProbeSent(now, 1000);
// Let time pass, no large enough packets put into prober.
@@ -105,10 +105,10 @@
BitrateProber prober(config);
prober.SetEnabled(true);
- EXPECT_FALSE(prober.IsProbing());
+ EXPECT_FALSE(prober.is_probing());
prober.OnIncomingPacket(100);
- EXPECT_FALSE(prober.IsProbing());
+ EXPECT_FALSE(prober.is_probing());
}
TEST(BitrateProberTest, VerifyProbeSizeOnHighBitrate) {
@@ -136,11 +136,11 @@
prober.CreateProbeCluster(kBitrate, now, 0);
prober.OnIncomingPacket(kPacketSizeBytes);
for (int i = 0; i < 5; ++i) {
- EXPECT_TRUE(prober.IsProbing());
+ EXPECT_TRUE(prober.is_probing());
prober.ProbeSent(now, kPacketSizeBytes);
}
- EXPECT_FALSE(prober.IsProbing());
+ EXPECT_FALSE(prober.is_probing());
}
TEST(BitrateProberTest, ScaleBytesUsedForProbing) {
@@ -155,12 +155,12 @@
prober.OnIncomingPacket(kPacketSizeBytes);
int bytes_sent = 0;
while (bytes_sent < kExpectedBytesSent) {
- ASSERT_TRUE(prober.IsProbing());
+ ASSERT_TRUE(prober.is_probing());
prober.ProbeSent(now, kPacketSizeBytes);
bytes_sent += kPacketSizeBytes;
}
- EXPECT_FALSE(prober.IsProbing());
+ EXPECT_FALSE(prober.is_probing());
}
TEST(BitrateProberTest, HighBitrateProbing) {
@@ -175,12 +175,12 @@
prober.OnIncomingPacket(kPacketSizeBytes);
int bytes_sent = 0;
while (bytes_sent < kExpectedBytesSent) {
- ASSERT_TRUE(prober.IsProbing());
+ ASSERT_TRUE(prober.is_probing());
prober.ProbeSent(now, kPacketSizeBytes);
bytes_sent += kPacketSizeBytes;
}
- EXPECT_FALSE(prober.IsProbing());
+ EXPECT_FALSE(prober.is_probing());
}
TEST(BitrateProberTest, ProbeClusterTimeout) {
@@ -195,22 +195,22 @@
Timestamp now = Timestamp::Millis(0);
prober.CreateProbeCluster(kBitrate, now, /*cluster_id=*/0);
prober.OnIncomingPacket(kSmallPacketSize);
- EXPECT_FALSE(prober.IsProbing());
+ EXPECT_FALSE(prober.is_probing());
now += kTimeout;
prober.CreateProbeCluster(kBitrate / 10, now, /*cluster_id=*/1);
prober.OnIncomingPacket(kSmallPacketSize);
- EXPECT_FALSE(prober.IsProbing());
+ EXPECT_FALSE(prober.is_probing());
now += TimeDelta::Millis(1);
prober.CreateProbeCluster(kBitrate / 10, now, /*cluster_id=*/2);
prober.OnIncomingPacket(kSmallPacketSize);
- EXPECT_TRUE(prober.IsProbing());
+ EXPECT_TRUE(prober.is_probing());
int bytes_sent = 0;
while (bytes_sent < kExpectedBytesSent) {
- ASSERT_TRUE(prober.IsProbing());
+ ASSERT_TRUE(prober.is_probing());
prober.ProbeSent(now, kSmallPacketSize);
bytes_sent += kSmallPacketSize;
}
- EXPECT_FALSE(prober.IsProbing());
+ EXPECT_FALSE(prober.is_probing());
}
} // namespace webrtc
diff --git a/modules/pacing/pacing_controller.cc b/modules/pacing/pacing_controller.cc
index 8d41963..70f39f5 100644
--- a/modules/pacing/pacing_controller.cc
+++ b/modules/pacing/pacing_controller.cc
@@ -327,7 +327,7 @@
}
// If probing is active, that always takes priority.
- if (prober_.IsProbing()) {
+ if (prober_.is_probing()) {
Timestamp probe_time = prober_.NextProbeTime(now);
// |probe_time| == PlusInfinity indicates no probe scheduled.
if (probe_time != Timestamp::PlusInfinity() && !probing_send_failure_) {
@@ -462,7 +462,7 @@
}
bool first_packet_in_probe = false;
- bool is_probing = prober_.IsProbing();
+ bool is_probing = prober_.is_probing();
PacedPacketInfo pacing_info;
absl::optional<DataSize> recommended_probe_size;
if (is_probing) {