[polari] roomList: Clarify a helper function
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari] roomList: Clarify a helper function
- Date: Thu, 4 Apr 2019 18:35:52 +0000 (UTC)
commit fafe095e4b0ccf3e2d19134313a87222901ecccc
Author: Florian Müllner <fmuellner gnome org>
Date: Thu Apr 4 00:31:23 2019 +0200
roomList: Clarify a helper function
for-loops with multiple variables are hard to read, come up with
an easier (and more concise) alternative.
https://gitlab.gnome.org/GNOME/polari/merge_requests/109
src/roomList.js | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
---
diff --git a/src/roomList.js b/src/roomList.js
index ca10a5a..a033fab 100644
--- a/src/roomList.js
+++ b/src/roomList.js
@@ -524,12 +524,8 @@ class RoomList extends Gtk.ListBox {
}
_roomToRowIndex(index) {
- let nChildren = this.get_children().length;
- for (let i = 0, roomIndex = 0; i < nChildren; i++) {
- if (this.get_row_at_index(i).room && roomIndex++ == index)
- return i;
- }
- return -1;
+ let roomRows = this.get_children().filter(r => r instanceof RoomRow);
+ return index < roomRows.length ? roomRows[index].get_index() : -1;
}
_getRoomRowAtIndex(index) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]