diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2017-06-30 09:31:19 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2017-06-30 09:31:19 +0300 |
commit | 61847b9d809d66928f297066f92c59ff280efeeb (patch) | |
tree | 40438fde150e87a59bb0d62139da1e494441ad56 | |
parent | 5ad46457799b775260b718439e73c382e1657888 (diff) | |
download | mariadb-git-61847b9d809d66928f297066f92c59ff280efeeb.tar.gz |
Tablespace: Add iterator, const_iterator, begin(), end()
-rw-r--r-- | storage/innobase/fsp/fsp0space.cc | 28 | ||||
-rw-r--r-- | storage/innobase/include/fsp0space.h | 18 |
2 files changed, 23 insertions, 23 deletions
diff --git a/storage/innobase/fsp/fsp0space.cc b/storage/innobase/fsp/fsp0space.cc index ea9c45697dc..94fae3d973b 100644 --- a/storage/innobase/fsp/fsp0space.cc +++ b/storage/innobase/fsp/fsp0space.cc @@ -39,11 +39,8 @@ bool Tablespace::intersection( const Tablespace* other_space) { - files_t::const_iterator end = other_space->m_files.end(); - - for (files_t::const_iterator it = other_space->m_files.begin(); - it != end; - ++it) { + for (files_t::const_iterator it(other_space->begin()), + end(other_space->end()); it != end; ++it) { if (find(it->m_filename)) { @@ -58,9 +55,7 @@ Tablespace::intersection( void Tablespace::shutdown() { - files_t::iterator end = m_files.end(); - - for (files_t::iterator it = m_files.begin(); it != end; ++it) { + for (iterator it = begin(); it != end(); ++it) { it->shutdown(); } @@ -95,10 +90,7 @@ Tablespace::open_or_create(bool is_temp) ut_ad(!m_files.empty()); - files_t::iterator begin = m_files.begin(); - files_t::iterator end = m_files.end(); - - for (files_t::iterator it = begin; it != end; ++it) { + for (iterator it = begin(); it != end(); ++it) { if (it->m_exists) { err = it->open_or_create( @@ -124,7 +116,7 @@ Tablespace::open_or_create(bool is_temp) the proper way. */ it->close(); - if (it == begin) { + if (it == begin()) { /* First data file. */ /* Create the tablespace entry for the multi-file @@ -154,11 +146,9 @@ Tablespace::open_or_create(bool is_temp) /** Find a filename in the list of Datafiles for a tablespace @return true if the filename exists in the data files */ bool -Tablespace::find(const char* filename) +Tablespace::find(const char* filename) const { - files_t::const_iterator end = m_files.end(); - - for (files_t::const_iterator it = m_files.begin(); it != end; ++it) { + for (const_iterator it = begin(); it != end(); ++it) { if (innobase_strcasecmp(filename, it->m_filename) == 0) { return(true); @@ -172,9 +162,7 @@ Tablespace::find(const char* filename) void Tablespace::delete_files() { - files_t::iterator end = m_files.end(); - - for (files_t::iterator it = m_files.begin(); it != end; ++it) { + for (iterator it = begin(); it != end(); ++it) { it->close(); diff --git a/storage/innobase/include/fsp0space.h b/storage/innobase/include/fsp0space.h index 5b5293666b5..2c28ecc5c7b 100644 --- a/storage/innobase/include/fsp0space.h +++ b/storage/innobase/include/fsp0space.h @@ -44,6 +44,10 @@ public: /** Data file information - each Datafile can be accessed globally */ files_t m_files; + /** Data file iterator */ + typedef files_t::iterator iterator; + /** Data file iterator */ + typedef files_t::const_iterator const_iterator; Tablespace() : @@ -68,6 +72,15 @@ public: Tablespace(const Tablespace&); Tablespace& operator=(const Tablespace&); + /** Data file iterator */ + const_iterator begin() const { return m_files.begin(); } + /** Data file iterator */ + const_iterator end() const { return m_files.end(); } + /** Data file iterator */ + iterator begin() { return m_files.begin(); } + /** Data file iterator */ + iterator end() { return m_files.end(); } + void set_name(const char* name) { m_name = name; } const char* name() const { return m_name; } @@ -156,8 +169,7 @@ public: { ulint sum = 0; - for (files_t::const_iterator it = m_files.begin(); - it != m_files.end(); ++it) { + for (const_iterator it = begin(); it != end(); ++it) { sum += it->m_size; } @@ -200,7 +212,7 @@ private: /** @param[in] filename Name to lookup in the data files. @return true if the filename exists in the data files */ - bool find(const char* filename); + bool find(const char* filename) const; /** Note that the data file was found. @param[in] file data file object */ |