mirror of
https://github.com/TextureGroup/Texture.git
synced 2026-04-07 19:17:39 +00:00
Fix Alignment of Hashed Structs (#287)
* Fix alignment of ASImageNodeContentsKey struct to fix hashing * Change the change log by logging a change * Add the world's stupidest explicit cast * Actually its simpler
This commit is contained in:
committed by
Adlai Holler
parent
850aeb442c
commit
33f2cd39bf
@@ -12,3 +12,4 @@
|
||||
- Move more properties from ASTableView, ASCollectionView to their respective node classes. [Adlai Holler](https://github.com/Adlai-Holler)
|
||||
- Remove finalLayoutElement [Michael Schneider] (https://github.com/maicki)[#96](https://github.com/TextureGroup/Texture/pull/96)
|
||||
- Add ASPageTable - A map table for fast retrieval of objects within a certain page [Huy Nguyen](https://github.com/nguyenhuy)
|
||||
- [Fix] Fix a major regression in our image node contents caching. [Adlai Holler](https://github.com/Adlai-Holler) [#287](https://github.com/TextureGroup/Texture/pull/287)
|
||||
|
||||
@@ -102,15 +102,18 @@ struct ASImageNodeDrawParameters {
|
||||
|
||||
- (NSUInteger)hash
|
||||
{
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic warning "-Wpadded"
|
||||
struct {
|
||||
NSUInteger imageHash;
|
||||
CGSize backingSize;
|
||||
CGRect imageDrawRect;
|
||||
BOOL isOpaque;
|
||||
NSInteger isOpaque;
|
||||
NSUInteger backgroundColorHash;
|
||||
void *willDisplayNodeContentWithRenderingContext;
|
||||
void *didDisplayNodeContentWithRenderingContext;
|
||||
void *imageModificationBlock;
|
||||
#pragma clang diagnostic pop
|
||||
} data = {
|
||||
_image.hash,
|
||||
_backingSize,
|
||||
|
||||
@@ -68,9 +68,12 @@ struct ASTextNodeDrawParameter {
|
||||
|
||||
- (NSUInteger)hash
|
||||
{
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic warning "-Wpadded"
|
||||
struct {
|
||||
size_t attributesHash;
|
||||
CGSize constrainedSize;
|
||||
#pragma clang diagnostic pop
|
||||
} data = {
|
||||
_attributes.hash(),
|
||||
_constrainedSize
|
||||
|
||||
@@ -34,6 +34,11 @@ ASDISPLAYNODE_EXTERN_C_BEGIN
|
||||
* _bounds.size
|
||||
* };
|
||||
* return ASHashBytes(&data, sizeof(data));
|
||||
*
|
||||
* @warning: If a struct has padding, any fields that are intiailized in {}
|
||||
* will have garbage data for their padding, which will break this hash! Either
|
||||
* use `pragma clang diagnostic warning "-Wpadded"` around your struct definition
|
||||
* or manually initialize the fields of your struct (`myStruct.x = 7;` etc).
|
||||
*/
|
||||
NSUInteger ASHashBytes(void *bytes, size_t length);
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@ NSString *const ASTextKitEntityAttributeName = @"ck_entity";
|
||||
|
||||
size_t ASTextKitAttributes::hash() const
|
||||
{
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic warning "-Wpadded"
|
||||
struct {
|
||||
NSUInteger attrStringHash;
|
||||
NSUInteger truncationStringHash;
|
||||
@@ -35,6 +37,7 @@ size_t ASTextKitAttributes::hash() const
|
||||
NSUInteger shadowColorHash;
|
||||
CGFloat shadowOpacity;
|
||||
CGFloat shadowRadius;
|
||||
#pragma clang diagnostic pop
|
||||
} data = {
|
||||
[attributedString hash],
|
||||
[truncationAttributedString hash],
|
||||
|
||||
Reference in New Issue
Block a user