replace calls to ExceptionOccurred with calls to ExceptionCheck

The latter is cheaper (avoids a state transition and possible memory
allocation) when we just want to know if an exception is thrown
without needing a handle to that exception.
This commit is contained in:
Joel Dice
2009-12-16 19:25:03 -07:00
parent 4c0ede8b9a
commit 30db38ebd6
5 changed files with 30 additions and 32 deletions

View File

@ -170,7 +170,7 @@ map(JNIEnv* e, const char* path)
void* data = MapViewOfFile(mapping, FILE_MAP_READ, 0, 0, 0);
if (data) {
void* p = allocate(e, sizeof(Mapping));
if (not e->ExceptionOccurred()) {
if (not e->ExceptionCheck()) {
result = new (p)
Mapping(static_cast<uint8_t*>(data), size, file, mapping);
}
@ -186,7 +186,7 @@ map(JNIEnv* e, const char* path)
CloseHandle(file);
}
}
if (result == 0 and not e->ExceptionOccurred()) {
if (result == 0 and not e->ExceptionCheck()) {
throwNew(e, "java/io/IOException", "%d", GetLastError());
}
return result;
@ -256,14 +256,14 @@ map(JNIEnv* e, const char* path)
void* data = mmap(0, s.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
if (data) {
void* p = allocate(e, sizeof(Mapping));
if (not e->ExceptionOccurred()) {
if (not e->ExceptionCheck()) {
result = new (p) Mapping(static_cast<uint8_t*>(data), s.st_size);
}
}
}
close(fd);
}
if (result == 0 and not e->ExceptionOccurred()) {
if (result == 0 and not e->ExceptionCheck()) {
throwNewErrno(e, "java/io/IOException");
}
return result;