@@ -55,25 +55,23 @@ CborError CBOREncoder::encode(PropertyContainer & property_container, uint8_t *
55
55
PropertyContainer::iterator iter = property_container.begin ();
56
56
std::advance (iter, current_property_index);
57
57
58
- std::for_each (iter,
59
- property_container.end (),
60
- [lightPayload, &arrayEncoder, &error, &num_encoded_properties, &num_checked_properties](Property * p)
61
- {
62
- bool maximum_number_of_properties_reached = (num_encoded_properties >= encoded_properties_message_limit) && (encoded_properties_message_limit != CBOR_ENCODER_NO_PROPERTIES_LIMIT);
63
- bool cbor_encoder_error = (error != CborNoError);
64
- if ((!cbor_encoder_error) && (!maximum_number_of_properties_reached))
65
- {
66
- if (p->shouldBeUpdated () && p->isReadableByCloud ())
67
- {
68
- error = p->append (&arrayEncoder, lightPayload);
69
- if (error == CborNoError)
70
- num_encoded_properties++;
71
- else
72
- return ;
73
- }
74
- num_checked_properties++;
75
- }
76
- });
58
+ for (; iter != property_container.end (); iter++)
59
+ {
60
+ Property * p = * iter;
61
+ bool maximum_number_of_properties_reached = (num_encoded_properties >= encoded_properties_message_limit) && (encoded_properties_message_limit != -1 );
62
+ bool cbor_encoder_error = (error != CborNoError);
63
+
64
+ if (maximum_number_of_properties_reached || cbor_encoder_error)
65
+ break ;
66
+
67
+ if (p->shouldBeUpdated () && p->isReadableByCloud ())
68
+ {
69
+ error = p->append (&arrayEncoder, lightPayload);
70
+ if (error == CborNoError)
71
+ num_encoded_properties++;
72
+ }
73
+ num_checked_properties++;
74
+ }
77
75
78
76
if ((CborNoError != error) && (CborErrorOutOfMemory != error))
79
77
{
@@ -97,16 +95,16 @@ CborError CBOREncoder::encode(PropertyContainer & property_container, uint8_t *
97
95
iter = property_container.begin ();
98
96
std::advance (iter, current_property_index);
99
97
int num_appended_properties = 0 ;
100
- std::for_each (iter,
101
- property_container.end (),
102
- [&num_appended_properties, &num_checked_properties](Property * p)
103
- {
104
- if (num_appended_properties < num_checked_properties)
105
- {
106
- p-> appendCompleted ();
107
- num_appended_properties++ ;
108
- }
109
- });
98
+
99
+ for (; iter != property_container.end (); iter++)
100
+ {
101
+ Property * p = * iter;
102
+ if (num_appended_properties >= num_checked_properties)
103
+ break ;
104
+
105
+ p-> appendCompleted () ;
106
+ num_appended_properties++;
107
+ }
110
108
111
109
/* Advance property index for the nex message */
112
110
current_property_index += num_checked_properties;
0 commit comments