Explorar el Código

Some database operations are const-safe

default_compile_flags
vector-of-bool hace 5 años
padre
commit
c182193931
Se han modificado 4 ficheros con 9 adiciones y 9 borrados
  1. +1
    -1
      src/dds/build/deps.cpp
  2. +1
    -1
      src/dds/build/deps.hpp
  3. +2
    -2
      src/dds/db/database.cpp
  4. +5
    -5
      src/dds/db/database.hpp

+ 1
- 1
src/dds/build/deps.cpp Ver fichero

@@ -74,7 +74,7 @@ void dds::update_deps_info(database& db, const deps_info& deps) {
}
}

deps_rebuild_info dds::get_rebuild_info(database& db, path_ref output_path) {
deps_rebuild_info dds::get_rebuild_info(const database& db, path_ref output_path) {
std::unique_lock lk{db.mutex()};
auto cmd_ = db.command_of(output_path);
if (!cmd_) {

+ 1
- 1
src/dds/build/deps.hpp Ver fichero

@@ -41,6 +41,6 @@ struct deps_rebuild_info {
std::string previous_command_output;
};

deps_rebuild_info get_rebuild_info(database& db, path_ref output_path);
deps_rebuild_info get_rebuild_info(const database& db, path_ref output_path);

} // namespace dds

+ 2
- 2
src/dds/db/database.cpp Ver fichero

@@ -162,7 +162,7 @@ void database::forget_inputs_of(path_ref file) {
sqlite3::exec(st, std::forward_as_tuple(fs::weakly_canonical(file).string()));
}

std::optional<std::vector<input_file_info>> database::inputs_of(path_ref file_) {
std::optional<std::vector<input_file_info>> database::inputs_of(path_ref file_) const {
auto file = fs::weakly_canonical(file_);
auto& st = _stmt_cache(R"(
WITH file AS (
@@ -191,7 +191,7 @@ std::optional<std::vector<input_file_info>> database::inputs_of(path_ref file_)
return ret;
}

std::optional<command_info> database::command_of(path_ref file_) {
std::optional<command_info> database::command_of(path_ref file_) const {
auto file = fs::weakly_canonical(file_);
auto& st = _stmt_cache(R"(
WITH file AS (

+ 5
- 5
src/dds/db/database.hpp Ver fichero

@@ -26,9 +26,9 @@ struct input_file_info {
};

class database {
neo::sqlite3::database _db;
neo::sqlite3::statement_cache _stmt_cache{_db};
mutable std::shared_mutex _mutex;
neo::sqlite3::database _db;
mutable neo::sqlite3::statement_cache _stmt_cache{_db};
mutable std::shared_mutex _mutex;

explicit database(neo::sqlite3::database db);
database(const database&) = delete;
@@ -49,8 +49,8 @@ public:
void store_file_command(path_ref file, const command_info& cmd);
void forget_inputs_of(path_ref file);

std::optional<std::vector<input_file_info>> inputs_of(path_ref file);
std::optional<command_info> command_of(path_ref file);
std::optional<std::vector<input_file_info>> inputs_of(path_ref file) const;
std::optional<command_info> command_of(path_ref file) const;
};

} // namespace dds

Cargando…
Cancelar
Guardar