forked from nxtbgthng/JSONKit
-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
a patch to suit with the modern objc #1
Merged
Merged
Conversation
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
Hashing was changed slightly to exploit the fact that a significant amount of real world JSON strings / keys will have a high percentage of ASCII characters. Cache aging was modified to use an AIMD (additive increase, multiplicative decrease) policy. When an item is found in the cache, its age is incremented by one using saturating arithmetic. Ages are "quasi-randomly" aged using unsigned right shifts, or in other words its age is divided in half. Since ages decrease far more quickly than they increase, the cache can quickly adapt and converge on the "hot set".
…n about. 1. Some of the string format argument specifiers used `%lu` to display `NSUInteger` values. `%lu` specifies a type of `unsigned long`, and `NSUInteger` maps to either `unsigned int` or `unsigned long`, depending on whether or not you're targeting a 32-bit or 64-bit ABI, respectively. On a 32-bit architecture (at least for the architectures / compilers that JSONKit will be used on), `unsigned long` and `unsigned int` just so happen to use the same primitive type- a 4 byte 32-bit value. On a 64-bit architecture (again, for the architectures / compilers that JSONKit will be used on), `unsigned int` stays the same at 4 bytes, however `unsigned long` grows to 64-bits / 8 bytes. The long and the short of it is this that using `%lu` allows you to easily support 32-bit and 64-bits with out a lot of effort. However, technically, the C standard says that `int` and `long` are strictly different ranks, and it's generally considered poor form to take advantage of platform specific details in this case. The proper fix is to add explicit type casts to `unsigned long`. This makes the implied behavior explicit, and eliminates the warnings from newer versions of the compiler. FYI, `gcc` did this for a long time and seems to be something that is either new or enabled by default in `clang` / `Xcode`. Other good warning flags you should consider enabling by default (from Xcode 4.3): Implicit Conversion to 32 Bit Type Suspicious Implicit Conversions Hidden Local Variables 2. Newer compiler warns about deprecated `id` `isa` usage. I found jwz's commentary about breaking API's pretty funny: http://www.jwz.org/blog/2012/06/i-have-ported-xscreensaver-to-the-iphone/
…rning. The current (at the time of this writing) version of the `clang` static analyzer is complaing that the `objects` pointer is `NULL`. This is a false positive warning from the analyzer.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
johnezang#158