Skip to content

Commit

Permalink
speed up rendering large amounts of collapsed joins/parts/quits
Browse files Browse the repository at this point in the history
  • Loading branch information
c99koder committed Apr 9, 2019
1 parent 4549180 commit 85f9745
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
3 changes: 2 additions & 1 deletion IRCCloud/Classes/CollapsedEvents.m
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,8 @@ -(NSString *)formatNick:(NSString *)nick mode:(NSString *)mode colorize:(BOOL)co
self->_server?_server.MODE_VOICED.lowercaseString:@"v":@"25B100"
};

NSMutableString *output = [[NSMutableString alloc] initWithFormat:@"%c", BOLD];
NSMutableString *output = [[NSMutableString alloc] initWithCapacity:100];
[output appendFormat:@"%c", BOLD];
BOOL showSymbol = [[NetworkConnection sharedInstance] prefs] && [[[[NetworkConnection sharedInstance] prefs] objectForKey:@"mode-showsymbol"] boolValue];

if(colorize && nick) {
Expand Down
26 changes: 20 additions & 6 deletions IRCCloud/Classes/EventsTableView.m
Original file line number Diff line number Diff line change
Expand Up @@ -835,8 +835,8 @@ - (void)insertEvent:(Event *)event backlog:(BOOL)backlog nextIsGrouped:(BOOL)nex
c.showChan = self->_collapsedEvents.showChan;
c.server = self->_server;
[c addEvent:event];
msg = [c collapse];
if(!nextIsGrouped) {
msg = [c collapse];
NSString *groupMsg = [self->_collapsedEvents collapse];
if(groupMsg == nil && [type isEqualToString:@"nickchange"])
groupMsg = [NSString stringWithFormat:@"%@ → %c%@%c", event.oldNick, BOLD, [self->_collapsedEvents formatNick:event.nick mode:event.fromMode colorize:NO displayName:nil], BOLD];
Expand Down Expand Up @@ -867,6 +867,8 @@ - (void)insertEvent:(Event *)event backlog:(BOOL)backlog nextIsGrouped:(BOOL)nex
}
event.rowType = ROW_SOCKETCLOSED;
}
} else {
msg = @"";
}
event.timestamp = nil;
} else {
Expand Down Expand Up @@ -1150,7 +1152,7 @@ - (void)insertEvent:(Event *)event backlog:(BOOL)backlog nextIsGrouped:(BOOL)nex
return;
}
[self _addItem:event eid:eid];
if(!event.formatted && event.formattedMsg.length > 0) {
if(!event.formatted && event.formattedMsg.length > 0 && !backlog) {
[self _format:event];
}

Expand Down Expand Up @@ -1950,15 +1952,22 @@ - (void)refresh {
NSArray *events = [[EventsDataSource sharedInstance] eventsForBuffer:self->_buffer.bid];
if(events.count) {
NSMutableDictionary *uuids = [[NSMutableDictionary alloc] init];
for(Event *e in events) {
for(int i = 0; i < events.count; i++) {
Event *e = [events objectAtIndex:i];
Event *next = (i < events.count - 1)?[events objectAtIndex:i+1]:nil;
if(e.childEventCount) {
e.formatted = nil;
e.formattedMsg = nil;
}
e.replyCount = 0;
[self insertEvent:e backlog:true nextIsGrouped:false];
if(e.formattedMsg && !e.formatted)
[self _format:e];
NSString *type = next.type;
if(next && _currentCollapsedEid != -1 && ![_expandedSectionEids objectForKey:@(_currentCollapsedEid)] &&
([type isEqualToString:@"joined_channel"] || [type isEqualToString:@"parted_channel"] || [type isEqualToString:@"nickchange"] || [type isEqualToString:@"quit"] || [type isEqualToString:@"user_channel_mode"])) {
NSDate *date = [NSDate dateWithTimeIntervalSince1970:next.time];
[self insertEvent:e backlog:YES nextIsGrouped:[_lastCollpasedDay isEqualToString:[self->_formatter stringFromDate:date]]];
} else {
[self insertEvent:e backlog:YES nextIsGrouped:NO];
}
[uuids setObject:@(YES) forKey:e.UUID];
}
for(NSString *uuid in _rowCache.allKeys) {
Expand All @@ -1968,6 +1977,11 @@ - (void)refresh {
self->_tableView.tableHeaderView = nil;
}

for(Event *e in _data) {
if(e.formattedMsg && !e.formatted)
[self _format:e];
}

if(backlogEid > 0) {
for(NSInteger i = self->_data.count-1 ; i >= 0; i--) {
Event *e = [self->_data objectAtIndex:i];
Expand Down

0 comments on commit 85f9745

Please sign in to comment.