diff --git a/apps/navmeshtool/navmesh.cpp b/apps/navmeshtool/navmesh.cpp index ca614d0cf6..cf18d7edc3 100644 --- a/apps/navmeshtool/navmesh.cpp +++ b/apps/navmeshtool/navmesh.cpp @@ -24,6 +24,7 @@ #include #include #include +#include namespace NavMeshTool { @@ -81,7 +82,7 @@ namespace NavMeshTool return DetourNavigator::resolveMeshSource(mDb, source, mNextShapeId); } - std::optional find(const std::string& worldspace, const TilePosition &tilePosition, + std::optional find(std::string_view worldspace, const TilePosition &tilePosition, const std::vector &input) override { std::optional result; @@ -98,7 +99,7 @@ namespace NavMeshTool void ignore() override { report(); } - void insert(const std::string& worldspace, const TilePosition& tilePosition, std::int64_t version, + void insert(std::string_view worldspace, const TilePosition& tilePosition, std::int64_t version, const std::vector& input, PreparedNavMeshData& data) override { data.mUserId = static_cast(mNextTileId); diff --git a/apps/navmeshtool/navmesh.hpp b/apps/navmeshtool/navmesh.hpp index 725f0cd6a4..ff837eebe7 100644 --- a/apps/navmeshtool/navmesh.hpp +++ b/apps/navmeshtool/navmesh.hpp @@ -4,7 +4,6 @@ #include #include -#include namespace DetourNavigator { diff --git a/components/detournavigator/generatenavmeshtile.hpp b/components/detournavigator/generatenavmeshtile.hpp index 511b8dfb8f..69afe426bc 100644 --- a/components/detournavigator/generatenavmeshtile.hpp +++ b/components/detournavigator/generatenavmeshtile.hpp @@ -36,12 +36,12 @@ namespace DetourNavigator virtual std::int64_t resolveMeshSource(const MeshSource& source) = 0; - virtual std::optional find(const std::string& worldspace, const TilePosition& tilePosition, + virtual std::optional find(std::string_view worldspace, const TilePosition& tilePosition, const std::vector& input) = 0; virtual void ignore() = 0; - virtual void insert(const std::string& worldspace, const TilePosition& tilePosition, + virtual void insert(std::string_view worldspace, const TilePosition& tilePosition, std::int64_t version, const std::vector& input, PreparedNavMeshData& data) = 0; virtual void update(std::int64_t tileId, std::int64_t version, PreparedNavMeshData& data) = 0; diff --git a/components/detournavigator/navmeshdb.cpp b/components/detournavigator/navmeshdb.cpp index ebff250ee0..425cf7d434 100644 --- a/components/detournavigator/navmeshdb.cpp +++ b/components/detournavigator/navmeshdb.cpp @@ -10,7 +10,6 @@ #include #include -#include #include #include @@ -136,7 +135,7 @@ namespace DetourNavigator return tileId; } - std::optional NavMeshDb::findTile(const std::string& worldspace, + std::optional NavMeshDb::findTile(std::string_view worldspace, const TilePosition& tilePosition, const std::vector& input) { Tile result; @@ -147,7 +146,7 @@ namespace DetourNavigator return result; } - std::optional NavMeshDb::getTileData(const std::string& worldspace, + std::optional NavMeshDb::getTileData(std::string_view worldspace, const TilePosition& tilePosition, const std::vector& input) { TileData result; @@ -159,7 +158,7 @@ namespace DetourNavigator return result; } - int NavMeshDb::insertTile(TileId tileId, const std::string& worldspace, const TilePosition& tilePosition, + int NavMeshDb::insertTile(TileId tileId, std::string_view worldspace, const TilePosition& tilePosition, TileVersion version, const std::vector& input, const std::vector& data) { const std::vector compressedInput = Misc::compress(input); @@ -180,7 +179,7 @@ namespace DetourNavigator return shapeId; } - std::optional NavMeshDb::findShapeId(const std::string& name, ShapeType type, + std::optional NavMeshDb::findShapeId(std::string_view name, ShapeType type, const Sqlite3::ConstBlob& hash) { ShapeId shapeId; @@ -189,7 +188,7 @@ namespace DetourNavigator return shapeId; } - int NavMeshDb::insertShape(ShapeId shapeId, const std::string& name, ShapeType type, + int NavMeshDb::insertShape(ShapeId shapeId, std::string_view name, ShapeType type, const Sqlite3::ConstBlob& hash) { return execute(*mDb, mInsertShape, shapeId, name, type, hash); @@ -207,7 +206,7 @@ namespace DetourNavigator return findTileQuery; } - void FindTile::bind(sqlite3& db, sqlite3_stmt& statement, const std::string& worldspace, + void FindTile::bind(sqlite3& db, sqlite3_stmt& statement, std::string_view worldspace, const TilePosition& tilePosition, const std::vector& input) { Sqlite3::bindParameter(db, statement, ":worldspace", worldspace); @@ -221,7 +220,7 @@ namespace DetourNavigator return getTileDataQuery; } - void GetTileData::bind(sqlite3& db, sqlite3_stmt& statement, const std::string& worldspace, + void GetTileData::bind(sqlite3& db, sqlite3_stmt& statement, std::string_view worldspace, const TilePosition& tilePosition, const std::vector& input) { Sqlite3::bindParameter(db, statement, ":worldspace", worldspace); @@ -235,7 +234,7 @@ namespace DetourNavigator return insertTileQuery; } - void InsertTile::bind(sqlite3& db, sqlite3_stmt& statement, TileId tileId, const std::string& worldspace, + void InsertTile::bind(sqlite3& db, sqlite3_stmt& statement, TileId tileId, std::string_view worldspace, const TilePosition& tilePosition, TileVersion version, const std::vector& input, const std::vector& data) { @@ -271,7 +270,7 @@ namespace DetourNavigator return findShapeIdQuery; } - void FindShapeId::bind(sqlite3& db, sqlite3_stmt& statement, const std::string& name, + void FindShapeId::bind(sqlite3& db, sqlite3_stmt& statement, std::string_view name, ShapeType type, const Sqlite3::ConstBlob& hash) { Sqlite3::bindParameter(db, statement, ":name", name); @@ -284,7 +283,7 @@ namespace DetourNavigator return insertShapeQuery; } - void InsertShape::bind(sqlite3& db, sqlite3_stmt& statement, ShapeId shapeId, const std::string& name, + void InsertShape::bind(sqlite3& db, sqlite3_stmt& statement, ShapeId shapeId, std::string_view name, ShapeType type, const Sqlite3::ConstBlob& hash) { Sqlite3::bindParameter(db, statement, ":shape_id", shapeId); diff --git a/components/detournavigator/navmeshdb.hpp b/components/detournavigator/navmeshdb.hpp index 636f1de000..09604e5706 100644 --- a/components/detournavigator/navmeshdb.hpp +++ b/components/detournavigator/navmeshdb.hpp @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include @@ -64,21 +63,21 @@ namespace DetourNavigator struct FindTile { static std::string_view text() noexcept; - static void bind(sqlite3& db, sqlite3_stmt& statement, const std::string& worldspace, + static void bind(sqlite3& db, sqlite3_stmt& statement, std::string_view worldspace, const TilePosition& tilePosition, const std::vector& input); }; struct GetTileData { static std::string_view text() noexcept; - static void bind(sqlite3& db, sqlite3_stmt& statement, const std::string& worldspace, + static void bind(sqlite3& db, sqlite3_stmt& statement, std::string_view worldspace, const TilePosition& tilePosition, const std::vector& input); }; struct InsertTile { static std::string_view text() noexcept; - static void bind(sqlite3& db, sqlite3_stmt& statement, TileId tileId, const std::string& worldspace, + static void bind(sqlite3& db, sqlite3_stmt& statement, TileId tileId, std::string_view worldspace, const TilePosition& tilePosition, TileVersion version, const std::vector& input, const std::vector& data); }; @@ -99,14 +98,14 @@ namespace DetourNavigator struct FindShapeId { static std::string_view text() noexcept; - static void bind(sqlite3& db, sqlite3_stmt& statement, const std::string& name, + static void bind(sqlite3& db, sqlite3_stmt& statement, std::string_view name, ShapeType type, const Sqlite3::ConstBlob& hash); }; struct InsertShape { static std::string_view text() noexcept; - static void bind(sqlite3& db, sqlite3_stmt& statement, ShapeId shapeId, const std::string& name, + static void bind(sqlite3& db, sqlite3_stmt& statement, ShapeId shapeId, std::string_view name, ShapeType type, const Sqlite3::ConstBlob& hash); }; } @@ -120,22 +119,22 @@ namespace DetourNavigator TileId getMaxTileId(); - std::optional findTile(const std::string& worldspace, + std::optional findTile(std::string_view worldspace, const TilePosition& tilePosition, const std::vector& input); - std::optional getTileData(const std::string& worldspace, + std::optional getTileData(std::string_view worldspace, const TilePosition& tilePosition, const std::vector& input); - int insertTile(TileId tileId, const std::string& worldspace, const TilePosition& tilePosition, + int insertTile(TileId tileId, std::string_view worldspace, const TilePosition& tilePosition, TileVersion version, const std::vector& input, const std::vector& data); int updateTile(TileId tileId, TileVersion version, const std::vector& data); ShapeId getMaxShapeId(); - std::optional findShapeId(const std::string& name, ShapeType type, const Sqlite3::ConstBlob& hash); + std::optional findShapeId(std::string_view name, ShapeType type, const Sqlite3::ConstBlob& hash); - int insertShape(ShapeId shapeId, const std::string& name, ShapeType type, const Sqlite3::ConstBlob& hash); + int insertShape(ShapeId shapeId, std::string_view name, ShapeType type, const Sqlite3::ConstBlob& hash); private: Sqlite3::Db mDb; diff --git a/components/detournavigator/navmeshdbutils.cpp b/components/detournavigator/navmeshdbutils.cpp index 86f81bfc51..71873972b9 100644 --- a/components/detournavigator/navmeshdbutils.cpp +++ b/components/detournavigator/navmeshdbutils.cpp @@ -6,19 +6,20 @@ #include #include +#include namespace DetourNavigator { namespace { - std::optional findShapeId(NavMeshDb& db, const std::string& name, ShapeType type, + std::optional findShapeId(NavMeshDb& db, std::string_view name, ShapeType type, const std::string& hash) { const Sqlite3::ConstBlob hashData {hash.data(), static_cast(hash.size())}; return db.findShapeId(name, type, hashData); } - ShapeId getShapeId(NavMeshDb& db, const std::string& name, ShapeType type, + ShapeId getShapeId(NavMeshDb& db, std::string_view name, ShapeType type, const std::string& hash, ShapeId& nextShapeId) { const Sqlite3::ConstBlob hashData {hash.data(), static_cast(hash.size())};