mirror of
https://github.com/matrix-org/sliding-sync.git
synced 2025-03-10 13:37:11 +00:00
recency comparator: avoid 2x map lookups
This commit is contained in:
parent
f5d588678d
commit
1ad581a3ec
@ -147,10 +147,12 @@ func (s *SortableRooms) comparatorSortByName(i, j int) int {
|
|||||||
|
|
||||||
func (s *SortableRooms) comparatorSortByRecency(i, j int) int {
|
func (s *SortableRooms) comparatorSortByRecency(i, j int) int {
|
||||||
ri, rj := s.resolveRooms(i, j)
|
ri, rj := s.resolveRooms(i, j)
|
||||||
if ri.GetLastInterestedEventTimestamp(s.listKey) == rj.GetLastInterestedEventTimestamp(s.listKey) {
|
tsRi := ri.GetLastInterestedEventTimestamp(s.listKey)
|
||||||
|
tsRj := rj.GetLastInterestedEventTimestamp(s.listKey)
|
||||||
|
if tsRi == tsRj {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
if ri.GetLastInterestedEventTimestamp(s.listKey) > rj.GetLastInterestedEventTimestamp(s.listKey) {
|
if tsRi > tsRj {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
return -1
|
return -1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user