-
Notifications
You must be signed in to change notification settings - Fork 806
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve the performance of -[NSObject valueForKeyPath:]. (#1005)
* Improve the performance of _NSKVCSplitKeypath by using CF functions. * Do not create NSInvocations for quick get on nil values. References #904.
- Loading branch information
Showing
3 changed files
with
87 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,58 @@ | ||
/** | ||
* type_encoding_cases.h - expects the APPLY_TYPE macro to be defined. This | ||
* macro is invoked once for every type and its Objective-C name. Use this | ||
* file when implementing things like the -unsignedIntValue family of methods. | ||
* For this case, the macro will be invoked with unsigned int as the type and | ||
* unsignedInt as the name. | ||
*/ | ||
#ifndef APPLY_TYPE | ||
#error Define APPLY_TYPE(type, name, capitalizedName, encodingChar) before including this file | ||
//****************************************************************************** | ||
// | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// | ||
// This code is licensed under the MIT License (MIT). | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
// | ||
//****************************************************************************** | ||
|
||
#pragma once | ||
|
||
// Each OBJC_APPLY_*_TYPE_ENCODINGS macro expects a single argument: the name | ||
// of a macro to apply for every type encoding. That macro should take the form | ||
// #define name(ctype, objectiveCName, CapitalizedObjectiveCName, typeEncodingCharacter) | ||
|
||
#if defined(_Bool) | ||
#define OBJC_APPLY_BOOL_TYPE_ENCODING(_APPLY_TYPE_MACRO) \ | ||
_APPLY_TYPE_MACRO(_Bool, bool, Bool, 'B') | ||
#else | ||
#define OBJC_APPLY_BOOL_TYPE_ENCODING(_APPLY_TYPE_MACRO) // Nothing | ||
#endif | ||
APPLY_TYPE(double, double, Double, 'd') | ||
APPLY_TYPE(float, float, Float, 'f') | ||
APPLY_TYPE(signed char, char, Char, 'c') | ||
APPLY_TYPE(int, int, Int, 'i') | ||
APPLY_TYPE(short, short, Short, 's') | ||
APPLY_TYPE(long, long, Long, 'l') | ||
APPLY_TYPE(long long, longLong, LongLong, 'q') | ||
//APPLY_TYPE(__int128, int128, Int128, 't') | ||
APPLY_TYPE(unsigned char, unsignedChar, UnsignedChar, 'C') | ||
APPLY_TYPE(unsigned short, unsignedShort, UnsignedShort, 'S') | ||
APPLY_TYPE(unsigned int, unsignedInt, UnsignedInt, 'I') | ||
APPLY_TYPE(unsigned long, unsignedLong, UnsignedLong, 'L') | ||
APPLY_TYPE(unsigned long long, unsignedLongLong, UnsignedLongLong, 'Q') | ||
|
||
#define OBJC_APPLY_NUMERIC_TYPE_ENCODINGS(_APPLY_TYPE_MACRO) \ | ||
_APPLY_TYPE_MACRO(double, double, Double, 'd') \ | ||
_APPLY_TYPE_MACRO(float, float, Float, 'f') \ | ||
_APPLY_TYPE_MACRO(signed char, char, Char, 'c') \ | ||
_APPLY_TYPE_MACRO(int, int, Int, 'i') \ | ||
_APPLY_TYPE_MACRO(short, short, Short, 's') \ | ||
_APPLY_TYPE_MACRO(long, long, Long, 'l') \ | ||
_APPLY_TYPE_MACRO(long long, longLong, LongLong, 'q') \ | ||
_APPLY_TYPE_MACRO(unsigned char, unsignedChar, UnsignedChar, 'C') \ | ||
_APPLY_TYPE_MACRO(unsigned short, unsignedShort, UnsignedShort, 'S') \ | ||
_APPLY_TYPE_MACRO(unsigned int, unsignedInt, UnsignedInt, 'I') \ | ||
_APPLY_TYPE_MACRO(unsigned long, unsignedLong, UnsignedLong, 'L') \ | ||
_APPLY_TYPE_MACRO(unsigned long long, unsignedLongLong, UnsignedLongLong, 'Q') \ | ||
OBJC_APPLY_BOOL_TYPE_ENCODING(_APPLY_TYPE_MACRO) | ||
|
||
//APPLY_TYPE(__int128, int128, Int128, 't') \ | ||
//APPLY_TYPE(unsigned __int128, unsignedInt128, UnsignedInt128, 'T') | ||
#ifdef NON_INTEGER_TYPES | ||
#undef NON_INTEGER_TYPES | ||
APPLY_TYPE(_Bool, bool, Bool, 'B') | ||
#ifndef SKIP_ID | ||
APPLY_TYPE(id, object, Object, '@') | ||
#endif | ||
APPLY_TYPE(Class, class, Class, '#') | ||
APPLY_TYPE(SEL, selector, Selector, ':') | ||
APPLY_TYPE(char*, cString, CString, '*') | ||
#endif | ||
#undef APPLY_TYPE | ||
|
||
#define OBJC_APPLY_OBJECTIVEC_TYPE_ENCODINGS(_APPLY_TYPE_MACRO) \ | ||
_APPLY_TYPE_MACRO(id, object, Object, '@') \ | ||
_APPLY_TYPE_MACRO(Class, class, Class, '#') \ | ||
_APPLY_TYPE_MACRO(SEL, selector, Selector, ':') | ||
#define OBJC_APPLY_POINTER_TYPE_ENCODINGS(_APPLY_TYPE_MACRO) \ | ||
_APPLY_TYPE_MACRO(char*, cString, CString, '*') | ||
|
||
#define OBJC_APPLY_ALL_TYPE_ENCODINGS(_APPLY_TYPE_MACRO) \ | ||
OBJC_APPLY_NUMERIC_TYPE_ENCODINGS(_APPLY_TYPE_MACRO) \ | ||
OBJC_APPLY_OBJECTIVEC_TYPE_ENCODINGS(_APPLY_TYPE_MACRO) \ | ||
OBJC_APPLY_POINTER_TYPE_ENCODINGS(_APPLY_TYPE_MACRO) |