@@ -36,10 +36,15 @@ - (instancetype)init
3636- (void )updateStateWithNewState : (ViewShadowNode::ConcreteState::Shared)state
3737 oldState : (ViewShadowNode::ConcreteState::Shared)oldState
3838{
39- // Unsubscribe from old observers
40- if (oldState) {
41- const auto & oldRequests = oldState->getData ().getBackgroundImageRequests ();
42- for (const auto & request : oldRequests) {
39+ const auto * oldRequests = oldState ? &oldState->getData ().getBackgroundImageRequests () : nullptr ;
40+ const auto * newRequests = state ? &state->getData ().getBackgroundImageRequests () : nullptr ;
41+
42+ if (oldRequests && newRequests && *oldRequests == *newRequests) {
43+ return ;
44+ }
45+
46+ if (oldRequests) {
47+ for (const auto & request : *oldRequests) {
4348 if (request.imageRequest ) {
4449 auto it = _uriToObserver.find (request.imageSource .uri );
4550 if (it != _uriToObserver.end ()) {
@@ -54,10 +59,8 @@ - (void)updateStateWithNewState:(ViewShadowNode::ConcreteState::Shared)state
5459 _uriToObserver.clear ();
5560 [_loadedImages removeAllObjects ];
5661
57- // Subscribe to new observers
58- if (state) {
59- const auto &newRequests = state->getData ().getBackgroundImageRequests ();
60- for (const auto &request : newRequests) {
62+ if (newRequests) {
63+ for (const auto &request : *newRequests) {
6164 if (request.imageRequest ) {
6265 const std::string &uri = request.imageSource .uri ;
6366 auto [it, inserted] = _uriToObserver.emplace (uri, self);
0 commit comments