Bug 1442599 - Part 1: Replace AutoScopedAssign with MakeScopeExit. r=jorendorff

--HG--
extra : rebase_source : 15f362a6976aedea503a983f14acfc6c626914f8
This commit is contained in:
André Bargull 2018-03-15 03:41:23 -07:00
Родитель 3b52a7becc
Коммит 9ed8b208a7
2 изменённых файлов: 6 добавлений и 22 удалений

Просмотреть файл

@ -10,6 +10,7 @@
#include "jsexn.h"
#include "mozilla/ScopeExit.h"
#include "mozilla/Sprintf.h"
#include <string.h>
@ -667,7 +668,11 @@ js::ErrorToException(JSContext* cx, JSErrorReport* reportp,
// Prevent infinite recursion.
if (cx->generatingError)
return;
AutoScopedAssign<bool> asa(&cx->generatingError.ref(), true);
cx->generatingError = true;
auto restore = mozilla::MakeScopeExit([cx] {
cx->generatingError = false;
});
// Create an exception object.
RootedString messageStr(cx, reportp->newMessageString(cx));

Просмотреть файл

@ -13,7 +13,6 @@
#include "mozilla/Assertions.h"
#include "mozilla/Compiler.h"
#include "mozilla/GuardObjects.h"
#include "mozilla/HashFunctions.h"
#include "mozilla/MathAlgorithms.h"
#include "mozilla/PodOperations.h"
@ -156,26 +155,6 @@ Max(T t1, T t2)
return t1 > t2 ? t1 : t2;
}
template<typename T>
class MOZ_RAII AutoScopedAssign
{
public:
AutoScopedAssign(T* addr, const T& value
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
: addr_(addr), old(*addr_)
{
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
*addr_ = value;
}
~AutoScopedAssign() { *addr_ = old; }
private:
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
T* addr_;
T old;
};
template <typename T, typename U>
static inline U
ComputeByteAlignment(T bytes, U alignment)