summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Schleifer <js@webkeks.org>2011-04-28 20:15:52 +0200
committerJonathan Schleifer <js@webkeks.org>2011-04-28 20:15:52 +0200
commit1b434f868c263f42aa16c2df610b03479dccc637 (patch)
tree1739bc6c01b3a84da7314f2c064df13cc94810b7
parent645b97adbc03802452fec784882d001a169cdb4b (diff)
Nicer description for empty collections.
-rw-r--r--src/OFArray.m6
-rw-r--r--src/OFDictionary.m16
-rw-r--r--src/OFList.m6
3 files changed, 22 insertions, 6 deletions
diff --git a/src/OFArray.m b/src/OFArray.m
index 7db8870f..f288f46d 100644
--- a/src/OFArray.m
+++ b/src/OFArray.m
@@ -398,9 +398,13 @@
- (OFString*)description
{
- OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
+ OFAutoreleasePool *pool;
OFMutableString *ret;
+ if ([array count] == 0)
+ return @"()";
+
+ pool = [[OFAutoreleasePool alloc] init];
ret = [[self componentsJoinedByString: @",\n"] mutableCopy];
@try {
diff --git a/src/OFDictionary.m b/src/OFDictionary.m
index 75418740..442b590b 100644
--- a/src/OFDictionary.m
+++ b/src/OFDictionary.m
@@ -710,13 +710,21 @@ struct of_dictionary_bucket of_dictionary_deleted_bucket = {};
- (OFString*)description
{
- OFMutableString *ret = [OFMutableString stringWithString: @"{\n"];
- OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init], *pool2;
- OFEnumerator *keyEnumerator = [self keyEnumerator];
- OFEnumerator *objectEnumerator = [self objectEnumerator];
+ OFMutableString *ret;
+ OFAutoreleasePool *pool, *pool2;
+ OFEnumerator *keyEnumerator;
+ OFEnumerator *objectEnumerator;
id key, object;
size_t i;
+ if (count == 0)
+ return @"{}";
+
+ ret = [OFMutableString stringWithString: @"{\n"];
+ pool = [[OFAutoreleasePool alloc] init];
+ keyEnumerator = [self keyEnumerator];
+ objectEnumerator = [self objectEnumerator];
+
i = 0;
pool2 = [[OFAutoreleasePool alloc] init];
diff --git a/src/OFList.m b/src/OFList.m
index 6f33d1c9..678b8161 100644
--- a/src/OFList.m
+++ b/src/OFList.m
@@ -286,10 +286,14 @@
- (OFString*)description
{
- OFMutableString *ret = [OFMutableString stringWithString: @"[\n"];
+ OFMutableString *ret;
OFAutoreleasePool *pool;
of_list_object_t *iter;
+ if (count == 0)
+ return @"[]";
+
+ ret = [OFMutableString stringWithString: @"[\n"];
pool = [[OFAutoreleasePool alloc] init];
for (iter = firstListObject; iter != NULL; iter = iter->next) {