0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-27 07:54:05 +01:00

ircd::db: Remove unnecessary shared_ptr for column instance.

This commit is contained in:
Jason Volk 2017-08-30 22:13:50 -07:00
parent e46faaf882
commit cbdd176819
2 changed files with 24 additions and 26 deletions

View file

@ -98,7 +98,7 @@ struct ircd::db::column
using iterator = const_iterator;
protected:
std::shared_ptr<database::column> c;
database::column *c;
public:
explicit operator const database &() const;
@ -134,7 +134,6 @@ struct ircd::db::column
void operator()(const sopts &, const std::initializer_list<delta> &);
void operator()(const delta &, const sopts & = {});
explicit column(std::shared_ptr<database::column> c);
column(database::column &c);
column(database &, const string_view &column);
column() = default;
@ -178,12 +177,12 @@ struct ircd::db::column::const_iterator
private:
gopts opts;
std::shared_ptr<database::column> c;
database::column *c;
std::unique_ptr<rocksdb::Iterator> it;
mutable value_type val;
friend class column;
const_iterator(std::shared_ptr<database::column>, std::unique_ptr<rocksdb::Iterator> &&, gopts = {});
const_iterator(database::column *const &, std::unique_ptr<rocksdb::Iterator> &&, gopts = {});
public:
explicit operator const database::snapshot &() const;

View file

@ -343,12 +343,16 @@ ircd::db::shared_from(const database::column &column)
//
// database
//
namespace ircd::db
{
database::description default_description;
}
ircd::db::database::database(std::string name,
std::string optstr)
:database
{
std::move(name), std::move(optstr), {}
std::move(name), std::move(optstr), default_description
}
{
}
@ -1933,25 +1937,6 @@ ircd::db::name(const column &column)
return name(c);
}
//
// column
//
ircd::db::column::column(database::column &c)
:c{shared_from(c)}
{
}
ircd::db::column::column(std::shared_ptr<database::column> c)
:c{std::move(c)}
{
}
ircd::db::column::column(database &d,
const string_view &column_name)
:c{shared_from(d[column_name])}
{}
void
ircd::db::flush(column &column,
const bool &blocking)
@ -2101,6 +2086,20 @@ ircd::db::has(column &column,
}
}
//
// column
//
ircd::db::column::column(database::column &c)
:c{&c}
{
}
ircd::db::column::column(database &d,
const string_view &column_name)
:c{&d[column_name]}
{}
void
ircd::db::column::operator()(const delta &delta,
const sopts &sopts)
@ -2274,11 +2273,11 @@ ircd::db::column::const_iterator::const_iterator()
{
}
ircd::db::column::const_iterator::const_iterator(std::shared_ptr<database::column> c,
ircd::db::column::const_iterator::const_iterator(database::column *const &c,
std::unique_ptr<rocksdb::Iterator> &&it,
gopts opts)
:opts{std::move(opts)}
,c{std::move(c)}
,c{c}
,it{std::move(it)}
{
//if(!has_opt(this->opts, get::READAHEAD))