aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2009-06-18 09:15:12 +0000
committerBibiko <bibiko@eva.mpg.de>2009-06-18 09:15:12 +0000
commit1ecd2ebc5c03bf369e0951923d966eecf04a2925 (patch)
tree6a762fd6fccbc29fd28a555e07a5ece125aeaa07
parentb54a768bc63b01475a79426ea519d22217a001c5 (diff)
downloadsequelpro-1ecd2ebc5c03bf369e0951923d966eecf04a2925.tar.gz
sequelpro-1ecd2ebc5c03bf369e0951923d966eecf04a2925.tar.bz2
sequelpro-1ecd2ebc5c03bf369e0951923d966eecf04a2925.zip
• added to CMMCPConnection: observeValueForKeyPath:@"ConsoleEnableLogging"
- now [delegate willQueryString:] will only be called if user set ConsoleEnableLogging to YES (~8% faster) --Note: this option to disable logging should be placed in the Import dialog with default = NO for importing as well
-rw-r--r--Source/CMMCPConnection.h1
-rw-r--r--Source/CMMCPConnection.m16
2 files changed, 15 insertions, 2 deletions
diff --git a/Source/CMMCPConnection.h b/Source/CMMCPConnection.h
index 6d0b0811..26590d85 100644
--- a/Source/CMMCPConnection.h
+++ b/Source/CMMCPConnection.h
@@ -74,6 +74,7 @@
BOOL retryAllowed;
BOOL delegateResponseToWillQueryString;
+ BOOL consoleLoggingEnabled;
IMP willQueryStringPtr;
diff --git a/Source/CMMCPConnection.m b/Source/CMMCPConnection.m
index 68056ba1..18d89e8b 100644
--- a/Source/CMMCPConnection.m
+++ b/Source/CMMCPConnection.m
@@ -276,6 +276,7 @@ static void forcePingTimeout(int signalNumber);
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willPerformQuery:)
name:@"SMySQLQueryWillBePerformed" object:nil];
+ [[NSUserDefaults standardUserDefaults] addObserver:self forKeyPath:@"ConsoleEnableLogging" options:NSKeyValueObservingOptionNew context:NULL];
return mConnected;
}
@@ -681,6 +682,16 @@ static void forcePingTimeout(int signalNumber);
}
+/**
+ * This method is called as part of Key Value Observing which is used to watch for prefernce changes which effect the interface.
+ */
+- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
+{
+ if ([keyPath isEqualToString:@"ConsoleEnableLogging"]) {
+ consoleLoggingEnabled = [[NSUserDefaults standardUserDefaults] boolForKey:@"ConsoleEnableLogging"];
+ }
+}
+
/*
* Override the standard queryString: method to default to the connection encoding, as before,
* before pssing on to queryString: usingEncoding:.
@@ -726,8 +737,9 @@ static void forcePingTimeout(int signalNumber);
// queryStartTime = clock();
- // Inform the delegate about the query
- if (delegateResponseToWillQueryString)
+ // Inform the delegate about the query if logging is enabled and
+ // delegate responds to willQueryString:
+ if (consoleLoggingEnabled && delegateResponseToWillQueryString)
(void)(NSString*)(*willQueryStringPtr)(delegate, @selector(willQueryString:), query);
// Derive the query string in the correct encoding