Skip to content

Commit

Permalink
Add a way to opt out of always-clear-data behavior in ASCollectionVie…
Browse files Browse the repository at this point in the history
…w and ASTableView (#1284)
  • Loading branch information
nguyenhuy committed Dec 20, 2018
1 parent ab0a00c commit 17e5604
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Schemas/configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"exp_dealloc_queue_v2",
"exp_collection_teardown",
"exp_framesetter_cache",
"exp_clear_data_during_deallocation"
"exp_skip_clear_data"
]
}
}
Expand Down
12 changes: 3 additions & 9 deletions Source/ASCollectionView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -581,15 +581,9 @@ - (void)_asyncDelegateOrDataSourceDidChange
{
ASDisplayNodeAssertMainThread();

if (_asyncDataSource == nil && _asyncDelegate == nil) {
if (ASActivateExperimentalFeature(ASExperimentalClearDataDuringDeallocation)) {
if (_isDeallocating) {
[_dataController clearData];
}
} else {
[_dataController clearData];
}
}
if (_asyncDataSource == nil && _asyncDelegate == nil && !ASActivateExperimentalFeature(ASExperimentalSkipClearData)) {
[_dataController clearData];
}
}

- (void)setCollectionViewLayout:(nonnull UICollectionViewLayout *)collectionViewLayout
Expand Down
2 changes: 1 addition & 1 deletion Source/ASExperimentalFeatures.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ typedef NS_OPTIONS(NSUInteger, ASExperimentalFeatures) {
ASExperimentalNetworkImageQueue = 1 << 5, // exp_network_image_queue
ASExperimentalCollectionTeardown = 1 << 6, // exp_collection_teardown
ASExperimentalFramesetterCache = 1 << 7, // exp_framesetter_cache
ASExperimentalClearDataDuringDeallocation = 1 << 8, // exp_clear_data_during_deallocation
ASExperimentalSkipClearData = 1 << 8, // exp_skip_clear_data
ASExperimentalDidEnterPreloadSkipASMLayout = 1 << 9, // exp_did_enter_preload_skip_asm_layout
ASExperimentalDisableAccessibilityCache = 1 << 10, // exp_disable_a11y_cache
ASExperimentalFeatureAll = 0xFFFFFFFF
Expand Down
2 changes: 1 addition & 1 deletion Source/ASExperimentalFeatures.mm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
@"exp_network_image_queue",
@"exp_collection_teardown",
@"exp_framesetter_cache",
@"exp_clear_data_during_deallocation",
@"exp_skip_clear_data",
@"exp_did_enter_preload_skip_asm_layout",
@"exp_disable_a11y_cache"]));

Expand Down
10 changes: 2 additions & 8 deletions Source/ASTableView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -514,14 +514,8 @@ - (void)_asyncDelegateOrDataSourceDidChange
{
ASDisplayNodeAssertMainThread();

if (_asyncDataSource == nil && _asyncDelegate == nil) {
if (ASActivateExperimentalFeature(ASExperimentalClearDataDuringDeallocation)) {
if (_isDeallocating) {
[_dataController clearData];
}
} else {
[_dataController clearData];
}
if (_asyncDataSource == nil && _asyncDelegate == nil && !ASActivateExperimentalFeature(ASExperimentalSkipClearData)) {
[_dataController clearData];
}
}

Expand Down
4 changes: 2 additions & 2 deletions Tests/ASConfigurationTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
ASExperimentalNetworkImageQueue,
ASExperimentalCollectionTeardown,
ASExperimentalFramesetterCache,
ASExperimentalClearDataDuringDeallocation,
ASExperimentalSkipClearData,
ASExperimentalDidEnterPreloadSkipASMLayout,
ASExperimentalDisableAccessibilityCache
};
Expand All @@ -49,7 +49,7 @@ + (NSArray *)names {
@"exp_network_image_queue",
@"exp_collection_teardown",
@"exp_framesetter_cache",
@"exp_clear_data_during_deallocation",
@"exp_skip_clear_data",
@"exp_did_enter_preload_skip_asm_layout",
@"exp_disable_a11y_cache"
];
Expand Down

0 comments on commit 17e5604

Please sign in to comment.