diff options
author | Stuart Connolly <stuart02@gmail.com> | 2017-03-22 00:26:45 +0000 |
---|---|---|
committer | Stuart Connolly <stuart02@gmail.com> | 2017-03-22 00:26:45 +0000 |
commit | 9ed7fd72477a52a9fcfd9401332bff93f7cc1c4a (patch) | |
tree | 6fa41f2e552958a0a0a4abe2d9767bd33f8ec111 /Source | |
parent | 5906a91397ed42e74ab7671c8b1e98fb9bbf8c73 (diff) | |
download | sequelpro-9ed7fd72477a52a9fcfd9401332bff93f7cc1c4a.tar.gz sequelpro-9ed7fd72477a52a9fcfd9401332bff93f7cc1c4a.tar.bz2 sequelpro-9ed7fd72477a52a9fcfd9401332bff93f7cc1c4a.zip |
Performance improvement for databases that contain lots of objects. When getting shell variables for bundles don't call the object names methods multiple times.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/SPDatabaseDocument.m | 51 |
1 files changed, 25 insertions, 26 deletions
diff --git a/Source/SPDatabaseDocument.m b/Source/SPDatabaseDocument.m index c41d6179..3548c284 100644 --- a/Source/SPDatabaseDocument.m +++ b/Source/SPDatabaseDocument.m @@ -5785,56 +5785,55 @@ static int64_t SPDatabaseDocumentInstanceCounter = 0; - (NSDictionary *)shellVariables { - - if(!_isConnected) return @{}; + if (!_isConnected) return @{}; NSMutableDictionary *env = [NSMutableDictionary dictionary]; if (tablesListInstance) { - if([tablesListInstance selectedDatabase]) + + if ([tablesListInstance selectedDatabase]) { [env setObject:[tablesListInstance selectedDatabase] forKey:SPBundleShellVariableSelectedDatabase]; + } - if ([tablesListInstance tableName]) + if ([tablesListInstance tableName]) { [env setObject:[tablesListInstance tableName] forKey:SPBundleShellVariableSelectedTable]; + } - if ([tablesListInstance selectedTableItems]) + if ([tablesListInstance selectedTableItems]) { [env setObject:[[tablesListInstance selectedTableItems] componentsJoinedByString:@"\t"] forKey:SPBundleShellVariableSelectedTables]; + } - if ([tablesListInstance allDatabaseNames]) + if ([tablesListInstance allDatabaseNames]) { [env setObject:[[tablesListInstance allDatabaseNames] componentsJoinedByString:@"\t"] forKey:SPBundleShellVariableAllDatabases]; + } - if ([tablesListInstance allTableNames]) - [env setObject:[[tablesListInstance allTableNames] componentsJoinedByString:@"\t"] forKey:SPBundleShellVariableAllTables]; - - if ([tablesListInstance allViewNames]) - [env setObject:[[tablesListInstance allViewNames] componentsJoinedByString:@"\t"] forKey:SPBundleShellVariableAllViews]; - - if ([tablesListInstance allFunctionNames]) - [env setObject:[[tablesListInstance allFunctionNames] componentsJoinedByString:@"\t"] forKey:SPBundleShellVariableAllFunctions]; - - if ([tablesListInstance allProcedureNames]) - [env setObject:[[tablesListInstance allProcedureNames] componentsJoinedByString:@"\t"] forKey:SPBundleShellVariableAllProcedures]; - - if ([self user]) + if ([self user]) { [env setObject:[self user] forKey:SPBundleShellVariableCurrentUser]; + } - if ([self host]) + if ([self host]) { [env setObject:[self host] forKey:SPBundleShellVariableCurrentHost]; + } - if ([self port]) + if ([self port]) { [env setObject:[self port] forKey:SPBundleShellVariableCurrentPort]; + } - [env setObject:([self databaseEncoding])?:@"" forKey:SPBundleShellVariableDatabaseEncoding]; + [env setObject:[[tablesListInstance allTableNames] componentsJoinedByString:@"\t"] forKey:SPBundleShellVariableAllTables]; + [env setObject:[[tablesListInstance allViewNames] componentsJoinedByString:@"\t"] forKey:SPBundleShellVariableAllViews]; + [env setObject:[[tablesListInstance allFunctionNames] componentsJoinedByString:@"\t"] forKey:SPBundleShellVariableAllFunctions]; + [env setObject:[[tablesListInstance allProcedureNames] componentsJoinedByString:@"\t"] forKey:SPBundleShellVariableAllProcedures]; + [env setObject:([self databaseEncoding]) ? : @"" forKey:SPBundleShellVariableDatabaseEncoding]; } - if(1) - [env setObject:@"mysql" forKey:SPBundleShellVariableRDBMSType]; + [env setObject:@"mysql" forKey:SPBundleShellVariableRDBMSType]; - if([self mySQLVersion]) + if ([self mySQLVersion]) { [env setObject:[self mySQLVersion] forKey:SPBundleShellVariableRDBMSVersion]; + } - return (NSDictionary*)env; + return (NSDictionary *)env; } #endif |