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

} }
} }


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()}; std::unique_lock lk{db.mutex()};
auto cmd_ = db.command_of(output_path); auto cmd_ = db.command_of(output_path);
if (!cmd_) { if (!cmd_) {

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

std::string previous_command_output; 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 } // namespace dds

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

sqlite3::exec(st, std::forward_as_tuple(fs::weakly_canonical(file).string())); 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 file = fs::weakly_canonical(file_);
auto& st = _stmt_cache(R"( auto& st = _stmt_cache(R"(
WITH file AS ( WITH file AS (
return ret; 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 file = fs::weakly_canonical(file_);
auto& st = _stmt_cache(R"( auto& st = _stmt_cache(R"(
WITH file AS ( WITH file AS (

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

}; };


class database { 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); explicit database(neo::sqlite3::database db);
database(const database&) = delete; database(const database&) = delete;
void store_file_command(path_ref file, const command_info& cmd); void store_file_command(path_ref file, const command_info& cmd);
void forget_inputs_of(path_ref file); 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 } // namespace dds

Cargando…
Cancelar
Guardar