Artifact e44a0576ae9803c31a2831dd865c840466d75199f8c6601e3f7d0bad2f664ecf:
- File
src/OFArray_adjacentSubarray.m
— part of check-in
[68d32a92c1]
at
2014-06-16 15:06:26
on branch trunk
— Make return type of -[OFArray objects] const
After all, this might (and does for OFArray_adjacent!) return an
internal representation that must not be changed, so changes should be
prevented at compile-time. (user: js, size: 1622) [annotate] [blame] [check-ins using]
/* * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014 * Jonathan Schleifer <js@webkeks.org> * * All rights reserved. * * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE.QPL included in * the packaging of this file. * * Alternatively, it may be distributed under the terms of the GNU General * Public License, either version 2 or 3, which can be found in the file * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this * file. */ #include "config.h" #import "OFArray_adjacentSubarray.h" #import "OFArray_adjacent.h" #import "OFMutableArray_adjacent.h" @implementation OFArray_adjacentSubarray - (const id*)objects { return [_array objects] + _range.location; } - (bool)isEqual: (id)object { OFArray *otherArray; id const *objects, *otherObjects; size_t i; if ([object class] != [OFArray_adjacent class] && [object class] != [OFMutableArray_adjacent class] && [object class] != [OFArray_adjacentSubarray class]) return [super isEqual: object]; otherArray = object; if (_range.length != [otherArray count]) return false; objects = [self objects]; otherObjects = [otherArray objects]; for (i = 0; i < _range.length; i++) if (![objects[i] isEqual: otherObjects[i]]) return false; return true; } #ifdef OF_HAVE_BLOCKS - (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block { id const *objects = [self objects]; size_t i; bool stop = false; for (i = 0; i < _range.length && !stop; i++) block(objects[i], i, &stop); } #endif @end