Skip to content

Commit 7d4475b

Browse files
committed
Slight flash improvement
1 parent bf8c4ba commit 7d4475b

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

src/app/ReadHandler.cpp

+6-11
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* See the License for the specific language governing permissions and
1616
* limitations under the License.
1717
*/
18+
#include "app/AttributePathExpandIterator.h"
1819
#include "lib/support/CodeUtils.h"
1920
#include <app/AppConfig.h>
2021
#include <app/InteractionModelEngine.h>
@@ -854,18 +855,11 @@ void ReadHandler::ResetPathIterator()
854855

855856
void ReadHandler::AttributePathIsDirty(DataModel::Provider * apDataModel, const AttributePathParams & aAttributeChanged)
856857
{
857-
bool bHasNext = false;
858-
ConcreteAttributePath path;
859-
860858
mDirtyGeneration = mManagementCallback.GetInteractionModelEngine()->GetReportingEngine().GetDirtySetGeneration();
861859

862-
{
863-
// Inside a separate block, to allow the read and rollback to happen as one unit.
864-
// we want to look at what `next` would be but not actually change state as we need to reset the
865-
// current cluster
866-
PeekAttributePathExpandIterator iterator(apDataModel, mAttributePathExpandState);
867-
bHasNext = iterator.Next(path);
868-
}
860+
// we want to get the value, but not advance the state
861+
AttributePathExpandIterator::State tempState = mAttributePathExpandState;
862+
ConcreteAttributePath path;
869863

870864
// We won't reset the path iterator for every AttributePathIsDirty call to reduce the number of full data reports.
871865
// The iterator will be reset after finishing each report session.
@@ -876,7 +870,8 @@ void ReadHandler::AttributePathIsDirty(DataModel::Provider * apDataModel, const
876870
// TODO (#16699): Currently we can only guarantee the reports generated from a single path in the request are consistent. The
877871
// data might be inconsistent if the user send a request with two paths from the same cluster. We need to clearify the behavior
878872
// or make it consistent.
879-
if (bHasNext && (aAttributeChanged.HasWildcardEndpointId() || aAttributeChanged.mEndpointId == path.mEndpointId) &&
873+
if (AttributePathExpandIterator(apDataModel, tempState).Next(path) &&
874+
(aAttributeChanged.HasWildcardEndpointId() || aAttributeChanged.mEndpointId == path.mEndpointId) &&
880875
(aAttributeChanged.HasWildcardClusterId() || aAttributeChanged.mClusterId == path.mClusterId))
881876
{
882877
ChipLogDetail(DataManagement,

0 commit comments

Comments
 (0)