Skip to content

Commit

Permalink
Use MARISA_DEBUG_IF in scoped-*.h as opposed to MARISA_THROW_IF
Browse files Browse the repository at this point in the history
These are the only two places that we throw exceptions from header files
in non-debug mode.

With this change, developers can take the marisa library without being
forced to enable exceptions for their whole library / application.

IMO, self-reset does not seem to be fatal enough to throw in production
and MARISA_DEBUG_IF should be enough for us to catch it if we think it
should never happen.
  • Loading branch information
tony-mak committed Sep 24, 2020
1 parent ca018e9 commit 88c6d93
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion include/marisa/scoped-array.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class scoped_array {
}

void reset(T *array = NULL) {
MARISA_THROW_IF((array != NULL) && (array == array_), MARISA_RESET_ERROR);
MARISA_DEBUG_IF((array != NULL) && (array == array_), MARISA_RESET_ERROR);
scoped_array(array).swap(*this);
}

Expand Down
2 changes: 1 addition & 1 deletion include/marisa/scoped-ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class scoped_ptr {
}

void reset(T *ptr = NULL) {
MARISA_THROW_IF((ptr != NULL) && (ptr == ptr_), MARISA_RESET_ERROR);
MARISA_DEBUG_IF((ptr != NULL) && (ptr == ptr_), MARISA_RESET_ERROR);
scoped_ptr(ptr).swap(*this);
}

Expand Down

0 comments on commit 88c6d93

Please sign in to comment.