Skip to content

Commit d15d955

Browse files
committed
Move array non-empty check to static func
Signed-off-by: Anna Rift <[email protected]>
1 parent 8eeaed4 commit d15d955

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

frontend/include/chpl/uast/Array.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,14 @@ class Array final : public AstNode {
175175
rowIterStack.emplace_back(begin, end);
176176
}
177177

178+
static void assertNonEmptyArr(const Array* arr) {
179+
CHPL_ASSERT(arr->numExprs() > 0 && "empty arrays not supported");
180+
}
181+
178182
public:
179183
// Construct an iterator starting at the beginning of the array
180184
static FlatteningArrayIterator normal(const Array* iterand) {
181-
CHPL_ASSERT(iterand->numExprs() > 0 && "empty arrays not supported");
185+
assertNonEmptyArr(iterand);
182186
FlatteningArrayIterator ret(iterand->exprs().begin(),
183187
iterand->exprs().end());
184188
ret.descendDims();
@@ -187,7 +191,7 @@ class Array final : public AstNode {
187191

188192
// Construct an iterator starting at the end of the array
189193
static FlatteningArrayIterator end(const Array* iterand) {
190-
CHPL_ASSERT(iterand->numExprs() > 0 && "empty arrays not supported");
194+
assertNonEmptyArr(iterand);
191195
return FlatteningArrayIterator(iterand->exprs().end(),
192196
iterand->exprs().end());
193197
}

0 commit comments

Comments
 (0)