@@ -164,22 +164,21 @@ interval_sparse_arrayt::interval_sparse_arrayt(
164
164
}
165
165
}
166
166
167
- interval_sparse_arrayt interval_sparse_arrayt::of_array_list (
168
- const exprt &expr,
167
+ interval_sparse_arrayt::interval_sparse_arrayt (
168
+ const array_list_exprt &expr,
169
169
const exprt &extra_value)
170
+ : interval_sparse_arrayt(extra_value)
170
171
{
171
172
PRECONDITION (expr.operands ().size () % 2 == 0 );
172
- interval_sparse_arrayt sparse_array (extra_value);
173
173
for (std::size_t i = 0 ; i < expr.operands ().size (); i += 2 )
174
174
{
175
175
const auto index = numeric_cast<std::size_t >(expr.operands ()[i]);
176
176
INVARIANT (
177
177
expr.operands ()[i + 1 ].type () == extra_value.type (),
178
178
" all values in array should have the same type" );
179
179
if (index .has_value () && expr.operands ()[i + 1 ].id () != ID_unknown)
180
- sparse_array. entries [*index ] = expr.operands ()[i + 1 ];
180
+ entries[*index ] = expr.operands ()[i + 1 ];
181
181
}
182
- return sparse_array;
183
182
}
184
183
185
184
optionalt<interval_sparse_arrayt>
@@ -189,8 +188,8 @@ interval_sparse_arrayt::of_expr(const exprt &expr, const exprt &extra_value)
189
188
return interval_sparse_arrayt (*array_expr, extra_value);
190
189
if (const auto &with_expr = expr_try_dynamic_cast<with_exprt>(expr))
191
190
return interval_sparse_arrayt (*with_expr);
192
- if (expr. id () == ID_array_list )
193
- return of_array_list (expr , extra_value);
191
+ if (const auto &array_list = expr_try_dynamic_cast<array_list_exprt>(expr) )
192
+ return interval_sparse_arrayt (*array_list , extra_value);
194
193
return {};
195
194
}
196
195
0 commit comments