susumu.yata
null+****@clear*****
Tue May 28 15:58:24 JST 2013
susumu.yata 2013-05-28 15:58:24 +0900 (Tue, 28 May 2013) New Revision: 9edcfd234532adef19c8bed16134ff1cd5a30cc7 https://github.com/groonga/grnxx/commit/9edcfd234532adef19c8bed16134ff1cd5a30cc7 Message: Use operator bool() instead of is_valid(). Modified files: lib/grnxx/storage/header.cpp lib/grnxx/storage/header.hpp lib/grnxx/storage/storage_impl.cpp Modified: lib/grnxx/storage/header.cpp (+1 -1) =================================================================== --- lib/grnxx/storage/header.cpp 2013-05-28 15:21:41 +0900 (b7625c2) +++ lib/grnxx/storage/header.cpp 2013-05-28 15:58:24 +0900 (f891bab) @@ -61,7 +61,7 @@ Header::Header() } } -bool Header::is_valid() const { +Header::operator bool() const { return std::memcmp(format, HEADER_FORMAT, HEADER_FORMAT_SIZE) == 0; } Modified: lib/grnxx/storage/header.hpp (+1 -1) =================================================================== --- lib/grnxx/storage/header.hpp 2013-05-28 15:21:41 +0900 (3717aaa) +++ lib/grnxx/storage/header.hpp 2013-05-28 15:58:24 +0900 (4d434bb) @@ -84,7 +84,7 @@ struct Header { Header(); // Return true if the header seems to be correct. - bool is_valid() const; + explicit operator bool() const; // Initialize "format". void validate(); Modified: lib/grnxx/storage/storage_impl.cpp (+2 -2) =================================================================== --- lib/grnxx/storage/storage_impl.cpp 2013-05-28 15:21:41 +0900 (c7d1061) +++ lib/grnxx/storage/storage_impl.cpp 2013-05-28 15:58:24 +0900 (a469493) @@ -492,7 +492,7 @@ bool StorageImpl::open_storage(const char *path, StorageFlags flags) { return false; } header_ = static_cast<Header *>(root_chunk->address()); - if (!header_->is_valid()) { + if (!*header_) { return false; } if (!prepare_pointers()) { @@ -521,7 +521,7 @@ bool StorageImpl::open_or_create_storage(const char *path, StorageFlags flags, return false; } header_ = static_cast<Header *>(root_chunk->address()); - if (!header_->is_valid()) { + if (!*header_) { return false; } if (!prepare_pointers()) { -------------- next part -------------- HTML����������������������������... Download