ObjFW  Diff

Differences From Artifact [b5e17c6561]:

To Artifact [95bb1cf3d0]:


747
748
749
750
751
752
753
754
755

756
757
758
759

760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775

776
777
778
779
780

781
782
783
784
785
786
787

	[pool release];
}

- (OFDictionary*)mappedDictionaryUsingBlock: (of_dictionary_map_block_t)block
{
	OFMutableDictionary *new = [OFMutableDictionary dictionary];
	size_t i;


	for (i = 0; i < size; i++)
		if (data[i] != NULL && data[i] != DELETED)
			[new setObject: block(data[i]->key, data[i]->object)
				forKey: data[i]->key];


	/*
	 * Class swizzle the dictionary to be immutable. We declared the return
	 * type to be OFDictionary*, so it can't be modified anyway. But not
	 * swizzling it would create a real copy each time -[copy] is called.
	 */
	new->isa = [OFDictionary class];
	return new;
}

- (OFDictionary*)filteredDictionaryUsingBlock:
    (of_dictionary_filter_block_t)block
{
	OFMutableDictionary *new = [OFMutableDictionary dictionary];
	size_t i;


	for (i = 0; i < size; i++)
		if (data[i] != NULL && data[i] != DELETED)
			if (block(data[i]->key, data[i]->object))
				[new setObject: data[i]->object
					forKey: data[i]->key];


	/*
	 * Class swizzle the dictionary to be immutable. We declared the return
	 * type to be OFDictionary*, so it can't be modified anyway. But not
	 * swizzling it would create a real copy each time -[copy] is called.
	 */
	new->isa = [OFDictionary class];







<

>
|
<
|
|
>














<

>
|
<
|
|
|
>







747
748
749
750
751
752
753

754
755
756

757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773

774
775
776

777
778
779
780
781
782
783
784
785
786
787

	[pool release];
}

- (OFDictionary*)mappedDictionaryUsingBlock: (of_dictionary_map_block_t)block
{
	OFMutableDictionary *new = [OFMutableDictionary dictionary];


	[self enumerateKeysAndObjectsUsingBlock: ^ (id key, id object,
	    BOOL *stop) {

		[new setObject: block(key, object)
			forKey: key];
	}];

	/*
	 * Class swizzle the dictionary to be immutable. We declared the return
	 * type to be OFDictionary*, so it can't be modified anyway. But not
	 * swizzling it would create a real copy each time -[copy] is called.
	 */
	new->isa = [OFDictionary class];
	return new;
}

- (OFDictionary*)filteredDictionaryUsingBlock:
    (of_dictionary_filter_block_t)block
{
	OFMutableDictionary *new = [OFMutableDictionary dictionary];


	[self enumerateKeysAndObjectsUsingBlock: ^ (id key, id object,
	    BOOL *stop) {

		if (block(key, object))
			[new setObject: object
				forKey: key];
	}];

	/*
	 * Class swizzle the dictionary to be immutable. We declared the return
	 * type to be OFDictionary*, so it can't be modified anyway. But not
	 * swizzling it would create a real copy each time -[copy] is called.
	 */
	new->isa = [OFDictionary class];