From 052959a5d7f92a629445deffd990da315da5c856 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Tue, 30 Mar 2010 13:29:49 +0000 Subject: =?UTF-8?q?=E2=80=A2=20next=20trial=20to=20make=20getAllKeysOfDbSt?= =?UTF-8?q?ructure=20thread=20safe=20=E2=80=A2=20some=20speed=20improvemen?= =?UTF-8?q?ts=20for=20navigator=20-=20pre-calculate=20display=20string=20f?= =?UTF-8?q?or=20type=20info=20to=20avoid=20doing=20it=20all=20the=20time?= =?UTF-8?q?=20while=20refreshing=20the=20outline=20view=20=E2=80=A2=20supp?= =?UTF-8?q?ress=20double-clicking=20at=20a=20not=20yet=20queried=20db=20st?= =?UTF-8?q?ructure=20if=20the=20same=20connection=20is=20querying=20anothe?= =?UTF-8?q?r=20structure=20to=20avoid=20accessing=20the=20same=20storage?= =?UTF-8?q?=20objects=20from=20different=20threads=20(test)=20=E2=80=A2=20?= =?UTF-8?q?reload=20outline=20view=20after=20filtering=20in=20navigator=20?= =?UTF-8?q?runs=20in=20its=20own=20thread=20to=20avoid=20blocking=20SP=20?= =?UTF-8?q?=E2=80=A2=20fixed=20memory=20leaks=20while=20returning=20[obj?= =?UTF-8?q?=20copy]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m | 34 ++++++++++++++++++---- 1 file changed, 28 insertions(+), 6 deletions(-) (limited to 'Frameworks/MCPKit') diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m index 35d07a39..fd9842aa 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m @@ -33,6 +33,7 @@ #import "MCPStreamingResult.h" #import "MCPConnectionProxy.h" #import "MCPStringAdditions.h" +#import "RegexKitLite.h" #include #include @@ -1897,11 +1898,14 @@ void performThreadedKeepAlive(void *ptr) SPUniqueSchemaDelimiter, [[[self delegate] allDatabaseNames] componentsJoinedByString:SPUniqueSchemaDelimiter]] componentsSeparatedByString:SPUniqueSchemaDelimiter]; + for(id db in dbs) { - if(![[structure valueForKey:connectionID] objectForKey:[NSString stringWithFormat:@"%@%@%@", connectionID, SPUniqueSchemaDelimiter, db]]) { + NSString *dbid = [NSString stringWithFormat:@"%@%@%@", connectionID, SPUniqueSchemaDelimiter, db]; + if(![[structure valueForKey:connectionID] objectForKey:dbid]) { // NSLog(@"added db %@", db); removeAddFlag = YES; - [[structure valueForKey:connectionID] setObject:db forKey:[NSString stringWithFormat:@"%@%@%@", connectionID, SPUniqueSchemaDelimiter, db]]; + [[structure valueForKey:connectionID] setObject:db forKey:dbid]; + [allKeysofDbStructure addObject:dbid]; } } @@ -2078,6 +2082,7 @@ void performThreadedKeepAlive(void *ptr) while(row = mysql_fetch_row(theResult)) { NSString *field = [self stringWithUTF8CString:row[0]]; NSString *type = [self stringWithUTF8CString:row[1]]; + NSString *type_display = [type stringByReplacingOccurrencesOfRegex:@"\\(.*?,.*?\\)" withString:@"(…)"]; NSString *coll = [self stringWithUTF8CString:row[2]]; NSString *isnull = [self stringWithUTF8CString:row[3]]; NSString *key = [self stringWithUTF8CString:row[4]]; @@ -2097,7 +2102,7 @@ void performThreadedKeepAlive(void *ptr) if(![[[structure valueForKey:connectionID] valueForKey:db_id] valueForKey:table_id]) [[[structure valueForKey:connectionID] valueForKey:db_id] setObject:[NSMutableDictionary dictionary] forKey:table_id]; - [[[[structure valueForKey:connectionID] valueForKey:db_id] valueForKey:table_id] setObject:[NSArray arrayWithObjects:type, def, isnull, charset, coll, key, extra, priv, comment, [NSNumber numberWithUnsignedLongLong:uniqueCounter], nil] forKey:field_id]; + [[[[structure valueForKey:connectionID] valueForKey:db_id] valueForKey:table_id] setObject:[NSArray arrayWithObjects:type, def, isnull, charset, coll, key, extra, priv, comment, type_display, [NSNumber numberWithUnsignedLongLong:uniqueCounter], nil] forKey:field_id]; [[[[structure valueForKey:connectionID] valueForKey:db_id] valueForKey:table_id] setObject:@"0" forKey:@" struct_type "]; uniqueCounter++; } @@ -2126,6 +2131,7 @@ void performThreadedKeepAlive(void *ptr) while(row = mysql_fetch_row(theResult)) { NSString *field = [self stringWithUTF8CString:row[0]]; NSString *type = [self stringWithUTF8CString:row[1]]; + NSString *type_display = [type stringByReplacingOccurrencesOfRegex:@"\\(.*?,.*?\\)" withString:@"(…)"]; NSString *coll = [self stringWithUTF8CString:row[2]]; NSString *isnull = [self stringWithUTF8CString:row[3]]; NSString *key = [self stringWithUTF8CString:row[4]]; @@ -2145,7 +2151,7 @@ void performThreadedKeepAlive(void *ptr) if(![[[structure valueForKey:connectionID] valueForKey:db_id] valueForKey:table_id]) [[[structure valueForKey:connectionID] valueForKey:db_id] setObject:[NSMutableDictionary dictionary] forKey:table_id]; - [[[[structure valueForKey:connectionID] valueForKey:db_id] valueForKey:table_id] setObject:[NSArray arrayWithObjects:type, def, isnull, charset, coll, key, extra, priv, comment, [NSNumber numberWithUnsignedLongLong:uniqueCounter], nil] forKey:field_id]; + [[[[structure valueForKey:connectionID] valueForKey:db_id] valueForKey:table_id] setObject:[NSArray arrayWithObjects:type, def, isnull, charset, coll, key, extra, priv, comment, type_display, [NSNumber numberWithUnsignedLongLong:uniqueCounter], nil] forKey:field_id]; [[[[structure valueForKey:connectionID] valueForKey:db_id] valueForKey:table_id] setObject:@"1" forKey:@" struct_type "]; uniqueCounter++; } @@ -2213,7 +2219,7 @@ void performThreadedKeepAlive(void *ptr) */ - (NSDictionary *)getDbStructure { - return [structure copy]; + return [[structure copy] autorelease]; } /** @@ -2221,7 +2227,23 @@ void performThreadedKeepAlive(void *ptr) */ - (NSArray *)getAllKeysOfDbStructure { - return [allKeysofDbStructure copy]; + NSArray *r = nil; + @try + { + r = [NSArray arrayWithArray:allKeysofDbStructure]; + } + @catch(id ae) + { + @try + { + r = [NSArray arrayWithArray:allKeysofDbStructure]; + } + @catch(id ae) + { + return nil; + } + } + return r; } #pragma mark - -- cgit v1.2.3