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.
|
||||
*/
|
||||
#define ASTableViewDataSource ASTableDataSource
|
||||
@protocol ASTableDataSource <ASCommonTableViewDataSource, NSObject>
|
||||
|
||||
/**
|
||||
@@ -315,6 +314,8 @@
|
||||
|
||||
@end
|
||||
|
||||
@protocol ASTableViewDataSource <ASTableDataSource>
|
||||
@end
|
||||
|
||||
/**
|
||||
* This is a node-based UITableViewDelegate.
|
||||
@@ -322,7 +323,6 @@
|
||||
* Note that -tableView:heightForRowAtIndexPath: has been removed; instead, your custom ASCellNode subclasses are
|
||||
* responsible for deciding their preferred onscreen height in -calculateSizeThatFits:.
|
||||
*/
|
||||
#define ASTableViewDelegate ASTableDelegate
|
||||
@protocol ASTableDelegate <ASCommonTableViewDelegate, NSObject>
|
||||
|
||||
@optional
|
||||
@@ -358,3 +358,6 @@
|
||||
- (BOOL)shouldBatchFetchForTableView:(ASTableView *)tableView;
|
||||
|
||||
@end
|
||||
|
||||
@protocol ASTableViewDelegate <ASTableDelegate>;
|
||||
@end
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
#import "_ASCoreAnimationExtras.h"
|
||||
|
||||
#import "ASEqualityHelpers.h"
|
||||
#import "ASAssert.h"
|
||||
|
||||
extern void ASDisplayNodeSetupLayerContentsWithResizableImage(CALayer *layer, UIImage *image)
|
||||
@@ -87,7 +87,8 @@ static const struct _UIContentModeStringLUTEntry UIContentModeDescriptionLUT[] =
|
||||
{UIViewContentModeBottomRight, @"bottomRight"},
|
||||
};
|
||||
|
||||
NSString *ASDisplayNodeNSStringFromUIContentMode(UIViewContentMode contentMode) {
|
||||
NSString *ASDisplayNodeNSStringFromUIContentMode(UIViewContentMode contentMode)
|
||||
{
|
||||
for (int i=0; i< ARRAY_COUNT(UIContentModeDescriptionLUT); i++) {
|
||||
if (UIContentModeDescriptionLUT[i].contentMode == contentMode) {
|
||||
return UIContentModeDescriptionLUT[i].string;
|
||||
@@ -96,16 +97,10 @@ NSString *ASDisplayNodeNSStringFromUIContentMode(UIViewContentMode contentMode)
|
||||
return [NSString stringWithFormat:@"%d", (int)contentMode];
|
||||
}
|
||||
|
||||
UIViewContentMode ASDisplayNodeUIContentModeFromNSString(NSString *string) {
|
||||
// If you passed one of the constants (this is just an optimization to avoid string comparison)
|
||||
UIViewContentMode ASDisplayNodeUIContentModeFromNSString(NSString *string)
|
||||
{
|
||||
for (int i=0; i < ARRAY_COUNT(UIContentModeDescriptionLUT); i++) {
|
||||
if (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]) {
|
||||
if (ASObjectIsEqual(UIContentModeDescriptionLUT[i].string, string)) {
|
||||
return UIContentModeDescriptionLUT[i].contentMode;
|
||||
}
|
||||
}
|
||||
@@ -126,18 +121,12 @@ NSString *const ASDisplayNodeCAContentsGravityFromUIContentMode(UIViewContentMod
|
||||
|
||||
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++) {
|
||||
if (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]) {
|
||||
if (ASObjectIsEqual(UIContentModeCAGravityLUT[i].string, contentsGravity)) {
|
||||
return UIContentModeCAGravityLUT[i].contentMode;
|
||||
}
|
||||
}
|
||||
|
||||
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.");
|
||||
// If asserts disabled, fall back to this
|
||||
|
||||
Reference in New Issue
Block a user