summaryrefslogtreecommitdiff
path: root/modules/webrtc
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2021-07-26 17:50:35 +0200
committerRémi Verschelde <rverschelde@gmail.com>2021-07-26 19:27:11 +0200
commit92299989bd10fd9855b6d77bc2bfabae218d1eea (patch)
tree7102f96ac3722e82c2cae7ad8bd4a5b5e7961989 /modules/webrtc
parentfef27e9b5b9b125ff535513c80b45953e8717f7d (diff)
Use Ref<T> references as iterators where relevant
And const when possible.
Diffstat (limited to 'modules/webrtc')
-rw-r--r--modules/webrtc/webrtc_multiplayer_peer.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/modules/webrtc/webrtc_multiplayer_peer.cpp b/modules/webrtc/webrtc_multiplayer_peer.cpp
index 77857255c1..9b08a26aed 100644
--- a/modules/webrtc/webrtc_multiplayer_peer.cpp
+++ b/modules/webrtc/webrtc_multiplayer_peer.cpp
@@ -154,7 +154,7 @@ void WebRTCMultiplayerPeer::_find_next_peer() {
}
// After last.
while (E) {
- for (Ref<WebRTCDataChannel> F : E->get()->channels) {
+ for (const Ref<WebRTCDataChannel> &F : E->get()->channels) {
if (F->get_available_packet_count()) {
next_packet_peer = E->key();
return;
@@ -165,7 +165,7 @@ void WebRTCMultiplayerPeer::_find_next_peer() {
E = peer_map.front();
// Before last
while (E) {
- for (Ref<WebRTCDataChannel> F : E->get()->channels) {
+ for (const Ref<WebRTCDataChannel> &F : E->get()->channels) {
if (F->get_available_packet_count()) {
next_packet_peer = E->key();
return;
@@ -213,7 +213,7 @@ int WebRTCMultiplayerPeer::get_unique_id() const {
void WebRTCMultiplayerPeer::_peer_to_dict(Ref<ConnectedPeer> p_connected_peer, Dictionary &r_dict) {
Array channels;
- for (Ref<WebRTCDataChannel> F : p_connected_peer->channels) {
+ for (Ref<WebRTCDataChannel> &F : p_connected_peer->channels) {
channels.push_back(F);
}
r_dict["connection"] = p_connected_peer->connection;
@@ -297,7 +297,7 @@ Error WebRTCMultiplayerPeer::get_packet(const uint8_t **r_buffer, int &r_buffer_
_find_next_peer();
ERR_FAIL_V(ERR_UNAVAILABLE);
}
- for (Ref<WebRTCDataChannel> E : peer_map[next_packet_peer]->channels) {
+ for (Ref<WebRTCDataChannel> &E : peer_map[next_packet_peer]->channels) {
if (E->get_available_packet_count()) {
Error err = E->get_packet(r_buffer, r_buffer_size);
_find_next_peer();
@@ -357,7 +357,7 @@ int WebRTCMultiplayerPeer::get_available_packet_count() const {
}
int size = 0;
for (Map<int, Ref<ConnectedPeer>>::Element *E = peer_map.front(); E; E = E->next()) {
- for (Ref<WebRTCDataChannel> F : E->get()->channels) {
+ for (const Ref<WebRTCDataChannel> &F : E->get()->channels) {
size += F->get_available_packet_count();
}
}