mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-20 12:16:40 +00:00
* Source/GSPrivate.h (GS_REPLACE_CONSTANT_STRING): New macro.
* Source/externs.m: Initialize constant strings statically. (GSBuildStrings): Replace static strings with dynamic versions. * Testing/benchmark.m: Added tests for NSString -hash and -copy. Aligned ouput. * Testing/externs.m: New test. * Testing/GNUmakefile: Added externs.m test. Activated ADDITIONAL_TOOLS tests excluding gstcpport tests. * Source/Additions/GSCategories.m: Adjust declared lock type. Added comment. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@18058 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
4d1f1825c1
commit
fe44315405
7 changed files with 439 additions and 227 deletions
|
@ -48,6 +48,28 @@
|
|||
NSZoneFree(NSDefaultMallocZone(), _base); \
|
||||
}
|
||||
|
||||
/**
|
||||
* Macro to consistently replace public accessable
|
||||
* constant strings with dynamically allocated versions.
|
||||
* This method assumes an initialzed NSStringClass symbol
|
||||
* which contains the Class object of NSString. <br>
|
||||
* Most public accesable strings are used in collection classes
|
||||
* like NSDictionary, and therefor tend to receive -isEqual:
|
||||
* messages (and therefore -hash) rather often. Statically
|
||||
* allocated strings must calculate thier hash values where
|
||||
* dynamically allocated strings can store them. This optimization
|
||||
* is by far more effective than using NSString * const.
|
||||
* The backdraw is that the memory managent cannot enforce these values
|
||||
* to remain unaltered as it would for variables declared NSString * const.
|
||||
* Yet the optimization of the stored hash value is currently deemed
|
||||
* more important.
|
||||
*/
|
||||
#define GS_REPLACE_CONSTANT_STRING(ID) \
|
||||
ID = [[NSStringClass alloc] initWithCString: [ID cString]]
|
||||
/* Using cString here is OK here
|
||||
because NXConstantString returns a pointer
|
||||
to it's internal pointer. */
|
||||
|
||||
/*
|
||||
* Function to get the name of a string encoding as an NSString.
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue