mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Optimize string handling for CALayer gravity & UIView content mode. Finally fix protocol rename.
This commit is contained in:
@@ -277,7 +277,6 @@
|
|||||||
/**
|
/**
|
||||||
* This is a node-based UITableViewDataSource.
|
* This is a node-based UITableViewDataSource.
|
||||||
*/
|
*/
|
||||||
#define ASTableViewDataSource ASTableDataSource
|
|
||||||
@protocol ASTableDataSource <ASCommonTableViewDataSource, NSObject>
|
@protocol ASTableDataSource <ASCommonTableViewDataSource, NSObject>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -315,6 +314,8 @@
|
|||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@protocol ASTableViewDataSource <ASTableDataSource>
|
||||||
|
@end
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a node-based UITableViewDelegate.
|
* This is a node-based UITableViewDelegate.
|
||||||
@@ -322,7 +323,6 @@
|
|||||||
* Note that -tableView:heightForRowAtIndexPath: has been removed; instead, your custom ASCellNode subclasses are
|
* Note that -tableView:heightForRowAtIndexPath: has been removed; instead, your custom ASCellNode subclasses are
|
||||||
* responsible for deciding their preferred onscreen height in -calculateSizeThatFits:.
|
* responsible for deciding their preferred onscreen height in -calculateSizeThatFits:.
|
||||||
*/
|
*/
|
||||||
#define ASTableViewDelegate ASTableDelegate
|
|
||||||
@protocol ASTableDelegate <ASCommonTableViewDelegate, NSObject>
|
@protocol ASTableDelegate <ASCommonTableViewDelegate, NSObject>
|
||||||
|
|
||||||
@optional
|
@optional
|
||||||
@@ -357,4 +357,7 @@
|
|||||||
*/
|
*/
|
||||||
- (BOOL)shouldBatchFetchForTableView:(ASTableView *)tableView;
|
- (BOOL)shouldBatchFetchForTableView:(ASTableView *)tableView;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
@protocol ASTableViewDelegate <ASTableDelegate>;
|
||||||
|
@end
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#import "_ASCoreAnimationExtras.h"
|
#import "_ASCoreAnimationExtras.h"
|
||||||
|
#import "ASEqualityHelpers.h"
|
||||||
#import "ASAssert.h"
|
#import "ASAssert.h"
|
||||||
|
|
||||||
extern void ASDisplayNodeSetupLayerContentsWithResizableImage(CALayer *layer, UIImage *image)
|
extern void ASDisplayNodeSetupLayerContentsWithResizableImage(CALayer *layer, UIImage *image)
|
||||||
@@ -87,7 +87,8 @@ static const struct _UIContentModeStringLUTEntry UIContentModeDescriptionLUT[] =
|
|||||||
{UIViewContentModeBottomRight, @"bottomRight"},
|
{UIViewContentModeBottomRight, @"bottomRight"},
|
||||||
};
|
};
|
||||||
|
|
||||||
NSString *ASDisplayNodeNSStringFromUIContentMode(UIViewContentMode contentMode) {
|
NSString *ASDisplayNodeNSStringFromUIContentMode(UIViewContentMode contentMode)
|
||||||
|
{
|
||||||
for (int i=0; i< ARRAY_COUNT(UIContentModeDescriptionLUT); i++) {
|
for (int i=0; i< ARRAY_COUNT(UIContentModeDescriptionLUT); i++) {
|
||||||
if (UIContentModeDescriptionLUT[i].contentMode == contentMode) {
|
if (UIContentModeDescriptionLUT[i].contentMode == contentMode) {
|
||||||
return UIContentModeDescriptionLUT[i].string;
|
return UIContentModeDescriptionLUT[i].string;
|
||||||
@@ -96,16 +97,10 @@ NSString *ASDisplayNodeNSStringFromUIContentMode(UIViewContentMode contentMode)
|
|||||||
return [NSString stringWithFormat:@"%d", (int)contentMode];
|
return [NSString stringWithFormat:@"%d", (int)contentMode];
|
||||||
}
|
}
|
||||||
|
|
||||||
UIViewContentMode ASDisplayNodeUIContentModeFromNSString(NSString *string) {
|
UIViewContentMode ASDisplayNodeUIContentModeFromNSString(NSString *string)
|
||||||
// If you passed one of the constants (this is just an optimization to avoid string comparison)
|
{
|
||||||
for (int i=0; i < ARRAY_COUNT(UIContentModeDescriptionLUT); i++) {
|
for (int i=0; i < ARRAY_COUNT(UIContentModeDescriptionLUT); i++) {
|
||||||
if (UIContentModeDescriptionLUT[i].string == string) {
|
if (ASObjectIsEqual(UIContentModeDescriptionLUT[i].string, string)) {
|
||||||
return UIContentModeDescriptionLUT[i].contentMode;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// If you passed something isEqualToString: to one of the constants
|
|
||||||
for (int i=0; i < ARRAY_COUNT(UIContentModeDescriptionLUT); i++) {
|
|
||||||
if ([UIContentModeDescriptionLUT[i].string isEqualToString:string]) {
|
|
||||||
return UIContentModeDescriptionLUT[i].contentMode;
|
return UIContentModeDescriptionLUT[i].contentMode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -126,18 +121,12 @@ NSString *const ASDisplayNodeCAContentsGravityFromUIContentMode(UIViewContentMod
|
|||||||
|
|
||||||
UIViewContentMode ASDisplayNodeUIContentModeFromCAContentsGravity(NSString *const contentsGravity)
|
UIViewContentMode ASDisplayNodeUIContentModeFromCAContentsGravity(NSString *const contentsGravity)
|
||||||
{
|
{
|
||||||
// If you passed one of the constants (this is just an optimization to avoid string comparison)
|
|
||||||
for (int i=0; i < ARRAY_COUNT(UIContentModeCAGravityLUT); i++) {
|
for (int i=0; i < ARRAY_COUNT(UIContentModeCAGravityLUT); i++) {
|
||||||
if (UIContentModeCAGravityLUT[i].string == contentsGravity) {
|
if (ASObjectIsEqual(UIContentModeCAGravityLUT[i].string, contentsGravity)) {
|
||||||
return UIContentModeCAGravityLUT[i].contentMode;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// If you passed something isEqualToString: to one of the constants
|
|
||||||
for (int i=0; i < ARRAY_COUNT(UIContentModeCAGravityLUT); i++) {
|
|
||||||
if ([UIContentModeCAGravityLUT[i].string isEqualToString:contentsGravity]) {
|
|
||||||
return UIContentModeCAGravityLUT[i].contentMode;
|
return UIContentModeCAGravityLUT[i].contentMode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ASDisplayNodeCAssert(contentsGravity, @"Encountered an unknown contentsGravity \"%@\". Is this a new version of iOS?", contentsGravity);
|
ASDisplayNodeCAssert(contentsGravity, @"Encountered an unknown contentsGravity \"%@\". Is this a new version of iOS?", contentsGravity);
|
||||||
ASDisplayNodeCAssert(!contentsGravity, @"You passed nil to ASDisplayNodeUIContentModeFromCAContentsGravity. We're falling back to resize, but this is probably a bug.");
|
ASDisplayNodeCAssert(!contentsGravity, @"You passed nil to ASDisplayNodeUIContentModeFromCAContentsGravity. We're falling back to resize, but this is probably a bug.");
|
||||||
// If asserts disabled, fall back to this
|
// If asserts disabled, fall back to this
|
||||||
|
|||||||
Reference in New Issue
Block a user