aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPDotExporter.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-08-20 10:02:00 +0000
committerBibiko <bibiko@eva.mpg.de>2010-08-20 10:02:00 +0000
commitd17a6b638e529694685a333162bbf6fec6c7fc08 (patch)
tree5c72506af7bf75299c093ce6a47b7cc4a956e0ff /Source/SPDotExporter.m
parentdabf6466f11e5936ee871b8b3dd573020a142586 (diff)
downloadsequelpro-d17a6b638e529694685a333162bbf6fec6c7fc08.tar.gz
sequelpro-d17a6b638e529694685a333162bbf6fec6c7fc08.tar.bz2
sequelpro-d17a6b638e529694685a333162bbf6fec6c7fc08.zip
• overall replacement of:
[aString appendString:[NSString stringWithFormat:]] by [aString appendFormat:] since it's much more faster • first look at loop where several [aStr appendString:] occur to try to combine them into one appendString or appendFormat since the allocation of memory takes really time Note: I tested all my changes but we should test it further to be sure that I didn't a mistake!
Diffstat (limited to 'Source/SPDotExporter.m')
-rw-r--r--Source/SPDotExporter.m36
1 files changed, 17 insertions, 19 deletions
diff --git a/Source/SPDotExporter.m b/Source/SPDotExporter.m
index a2db43af..98644f32 100644
--- a/Source/SPDotExporter.m
+++ b/Source/SPDotExporter.m
@@ -83,15 +83,15 @@
[metaString setString:@"// ************************************************************\n"];
[metaString appendString:@"// Generated by: Sequel Pro\n"];
- [metaString appendString:[NSString stringWithFormat:@"// Version %@\n//\n", [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]]];
- [metaString appendString:[NSString stringWithFormat:@"// %@\n// %@\n//\n", SPLOCALIZEDURL_HOMEPAGE, SPDevURL]];
- [metaString appendString:[NSString stringWithFormat:@"// Host: %@ (MySQL %@)\n", [self dotDatabaseHost], [self dotDatabaseVersion]]];
- [metaString appendString:[NSString stringWithFormat:@"// Database: %@\n", [self dotDatabaseName]]];
- [metaString appendString:[NSString stringWithFormat:@"// Generation Time: %@\n", [NSDate date]]];
+ [metaString appendFormat:@"// Version %@\n//\n", [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]];
+ [metaString appendFormat:@"// %@\n// %@\n//\n", SPLOCALIZEDURL_HOMEPAGE, SPDevURL];
+ [metaString appendFormat:@"// Host: %@ (MySQL %@)\n", [self dotDatabaseHost], [self dotDatabaseVersion]];
+ [metaString appendFormat:@"// Database: %@\n", [self dotDatabaseName]];
+ [metaString appendFormat:@"// Generation Time: %@\n", [NSDate date]];
[metaString appendString:@"// ************************************************************\n\n"];
[metaString appendString:@"digraph \"Database Structure\" {\n"];
- [metaString appendString:[NSString stringWithFormat:@"\tlabel = \"ER Diagram: %@\";\n", [self dotDatabaseName]]];
+ [metaString appendFormat:@"\tlabel = \"ER Diagram: %@\";\n", [self dotDatabaseName]];
[metaString appendString:@"\tlabelloc = t;\n"];
[metaString appendString:@"\tcompound = true;\n"];
[metaString appendString:@"\tnode [ shape = record ];\n"];
@@ -132,16 +132,16 @@
[metaString setString:[NSString stringWithFormat:@"\tsubgraph \"table_%@\" {\n", tableName]];
[metaString appendString:@"\t\tnode [ shape = \"plaintext\" ];\n"];
- [metaString appendString:[NSString stringWithFormat:@"\t\t\"%@\" [ label=<\n", tableName]];
+ [metaString appendFormat:@"\t\t\"%@\" [ label=<\n", tableName];
[metaString appendString:@"\t\t\t<TABLE BORDER=\"0\" CELLSPACING=\"0\" CELLBORDER=\"1\">\n"];
- [metaString appendString:[NSString stringWithFormat:@"\t\t\t<TR><TD COLSPAN=\"3\" BGCOLOR=\"%@\">%@</TD></TR>\n", hdrColor, tableName]];
+ [metaString appendFormat:@"\t\t\t<TR><TD COLSPAN=\"3\" BGCOLOR=\"%@\">%@</TD></TR>\n", hdrColor, tableName];
// Get the column info
NSArray *columnInfo = [tableInfo objectForKey:@"columns"];
- for (NSInteger j = 0; j < [columnInfo count]; j++ )
+ for (NSDictionary* item in columnInfo)
{
- [metaString appendString:[NSString stringWithFormat:@"\t\t\t<TR><TD COLSPAN=\"3\" PORT=\"%@\">%@:<FONT FACE=\"Helvetica-Oblique\" POINT-SIZE=\"10\">%@</FONT></TD></TR>\n", [[columnInfo objectAtIndex:j] objectForKey:@"name"], [[columnInfo objectAtIndex:j] objectForKey:@"name"], [[columnInfo objectAtIndex:j] objectForKey:@"type"]]];
+ [metaString appendFormat:@"\t\t\t<TR><TD COLSPAN=\"3\" PORT=\"%@\">%@:<FONT FACE=\"Helvetica-Oblique\" POINT-SIZE=\"10\">%@</FONT></TD></TR>\n", [item objectForKey:@"name"], [item objectForKey:@"name"], [item objectForKey:@"type"]];
}
[metaString appendString:@"\t\t\t</TABLE>>\n"];
@@ -153,7 +153,8 @@
// see about relations
columnInfo = [tableInfo objectForKey:@"constraints"];
- for (NSInteger j = 0; j < [columnInfo count]; j++)
+ NSString *ccol = NSArrayObjectAtIndex(columnInfo, 0);
+ for (NSDictionary* item in columnInfo)
{
// Check for cancellation flag
if ([self isCancelled]) {
@@ -165,9 +166,8 @@
// Get the column references. Currently the columns themselves are an array,
// while reference columns and tables are comma separated if there are more than
// one. Only use the first of each for the time being.
- NSArray *ccols = [NSArrayObjectAtIndex(columnInfo, j) objectForKey:@"columns"];
- NSString *ccol = NSArrayObjectAtIndex(columnInfo, 0);
- NSString *rcol = [NSArrayObjectAtIndex(columnInfo, j) objectForKey:@"ref_columns"];
+ NSArray *ccols = [item objectForKey:@"columns"];
+ NSString *rcol = [item objectForKey:@"ref_columns"];
NSString *extra = @"";
@@ -176,7 +176,7 @@
rcol = NSArrayObjectAtIndex([rcol componentsSeparatedByString:@","], 0);
}
- [fkInfo addObject:[NSString stringWithFormat:@"%@:%@ -> %@:%@ %@", tableName, ccol, [NSArrayObjectAtIndex(columnInfo, j) objectForKey:@"ref_table"], rcol, extra]];
+ [fkInfo addObject:[NSString stringWithFormat:@"%@:%@ -> %@:%@ %@", tableName, ccol, [item objectForKey:@"ref_table"], rcol, extra]];
}
}
@@ -186,10 +186,8 @@
[metaString setString:@"edge [ arrowhead=inv, arrowtail=normal, style=dashed, color=\"#444444\" ];\n"];
// Get the relations
- for (NSInteger i = 0; i < [fkInfo count]; i++)
- {
- [metaString appendString:[NSString stringWithFormat:@"%@;\n", [fkInfo objectAtIndex:i]]];
- }
+ for (id item in fkInfo)
+ [metaString appendFormat:@"%@;\n", item];
[fkInfo release];