Skip to content
Snippets Groups Projects
Commit f6a9af6d authored by George Nachman's avatar George Nachman
Browse files

Rate limit instant triggers to .5 seconds

parent c0dec24a
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -91,6 +91,9 @@ static NSString *kTmuxFontChanged = @"kTmuxFontChanged";
 
static int gNextSessionID = 1;
 
// Rate limit for checking instant (partial-line) triggers, in seconds.
static NSTimeInterval kMinimumPartialLineTriggerCheckInterval = 0.5;
typedef enum {
TMUX_NONE,
TMUX_GATEWAY, // Receiving tmux protocol messages
Loading
Loading
@@ -239,6 +242,10 @@ typedef enum {
 
// Number of bytes received since an echo probe was sent.
int _bytesReceivedSinceSendingEchoProbe;
// The last time at which a partial-line trigger check occurred. This keeps us from wasting CPU
// checking long lines over and over.
NSTimeInterval _lastPartialLineTriggerCheck;
}
 
- (id)init {
Loading
Loading
@@ -1237,6 +1244,11 @@ typedef enum {
}
 
- (void)checkPartialLineTriggers {
NSTimeInterval now = [NSDate timeIntervalSinceReferenceDate];
if (now - _lastPartialLineTriggerCheck < kMinimumPartialLineTriggerCheckInterval) {
return;
}
_lastPartialLineTriggerCheck = now;
for (Trigger *trigger in _triggers) {
[trigger tryString:_triggerLine
inSession:self
Loading
Loading
@@ -2593,7 +2605,7 @@ static long long timeInTenthsOfSeconds(struct timeval t)
if (_tailFindTimer && [[[_view findViewController] view] isHidden]) {
[self stopTailFind];
}
[self checkPartialLineTriggers];
_timerRunning = NO;
}
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment