From c35cbf038d0992887b8d4bcf5d4ff83c323ec60c Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 8 Dec 2019 18:03:43 +0100 Subject: Cleanup: Avoid parameter copying overhead --- src/Parser.cpp | 138 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 67 insertions(+), 71 deletions(-) (limited to 'src/Parser.cpp') diff --git a/src/Parser.cpp b/src/Parser.cpp index e8599cf5..c1d8554d 100644 --- a/src/Parser.cpp +++ b/src/Parser.cpp @@ -86,7 +86,7 @@ Parser::find_resources(Sord::World& world, } static boost::optional -get_path(const URI base, const URI uri) +get_path(const URI& base, const URI& uri) { const URI relative = uri.make_relative(base); const std::string uri_str = "/" + relative.string(); @@ -104,11 +104,11 @@ skip_property(ingen::URIs& uris, const Sord::Node& predicate) } static Properties -get_properties(ingen::World& world, - Sord::Model& model, - const Sord::Node& subject, - Resource::Graph ctx, - boost::optional data = {}) +get_properties(ingen::World& world, + Sord::Model& model, + const Sord::Node& subject, + Resource::Graph ctx, + const boost::optional& data = {}) { AtomForge forge(world.uri_map().urid_map_feature()->urid_map); @@ -202,36 +202,36 @@ get_port(ingen::World& world, static boost::optional parse( - World& world, - Interface& target, - Sord::Model& model, - const URI& base_uri, - Sord::Node& subject, - boost::optional parent = boost::optional(), - boost::optional symbol = boost::optional(), - boost::optional data = boost::optional()); + World& world, + Interface& target, + Sord::Model& model, + const URI& base_uri, + Sord::Node& subject, + const boost::optional& parent = boost::optional(), + const boost::optional& symbol = boost::optional(), + const boost::optional& data = boost::optional()); static boost::optional parse_graph( - World& world, - Interface& target, - Sord::Model& model, - const URI& base_uri, - const Sord::Node& subject, - Resource::Graph ctx, - boost::optional parent = boost::optional(), - boost::optional symbol = boost::optional(), - boost::optional data = boost::optional()); + World& world, + Interface& target, + Sord::Model& model, + const URI& base_uri, + const Sord::Node& subject, + Resource::Graph ctx, + const boost::optional& parent = boost::optional(), + const boost::optional& symbol = boost::optional(), + const boost::optional& data = boost::optional()); static boost::optional parse_block( - World& world, - Interface& target, - Sord::Model& model, - const URI& base_uri, - const Sord::Node& subject, - const Raul::Path& path, - boost::optional data = boost::optional()); + World& world, + Interface& target, + Sord::Model& model, + const URI& base_uri, + const Sord::Node& subject, + const Raul::Path& path, + const boost::optional& data = boost::optional()); static bool parse_arcs( @@ -243,13 +243,13 @@ parse_arcs( const Raul::Path& graph); static boost::optional -parse_block(ingen::World& world, - ingen::Interface& target, - Sord::Model& model, - const URI& base_uri, - const Sord::Node& subject, - const Raul::Path& path, - boost::optional data) +parse_block(ingen::World& world, + ingen::Interface& target, + Sord::Model& model, + const URI& base_uri, + const Sord::Node& subject, + const Raul::Path& path, + const boost::optional& data) { const URIs& uris = world.uris(); @@ -317,15 +317,15 @@ parse_block(ingen::World& world, } static boost::optional -parse_graph(ingen::World& world, - ingen::Interface& target, - Sord::Model& model, - const URI& base_uri, - const Sord::Node& subject, - Resource::Graph ctx, - boost::optional parent, - boost::optional symbol, - boost::optional data) +parse_graph(ingen::World& world, + ingen::Interface& target, + Sord::Model& model, + const URI& base_uri, + const Sord::Node& subject, + Resource::Graph ctx, + const boost::optional& parent, + const boost::optional& symbol, + const boost::optional& data) { const URIs& uris = world.uris(); @@ -345,10 +345,6 @@ parse_graph(ingen::World& world, graph_path = Raul::Path("/"); } - if (!symbol) { - symbol = Raul::Symbol("_"); - } - // Create graph Properties props = get_properties(world, model, subject, ctx, data); target.put(path_to_uri(graph_path), props, ctx); @@ -503,14 +499,14 @@ parse_arcs(ingen::World& world, } static boost::optional -parse(ingen::World& world, - ingen::Interface& target, - Sord::Model& model, - const URI& base_uri, - Sord::Node& subject, - boost::optional parent, - boost::optional symbol, - boost::optional data) +parse(ingen::World& world, + ingen::Interface& target, + Sord::Model& model, + const URI& base_uri, + Sord::Node& subject, + const boost::optional& parent, + const boost::optional& symbol, + const boost::optional& data) { const URIs& uris = world.uris(); @@ -582,12 +578,12 @@ parse(ingen::World& world, } bool -Parser::parse_file(ingen::World& world, - ingen::Interface& target, - const FilePath& path, - boost::optional parent, - boost::optional symbol, - boost::optional data) +Parser::parse_file(ingen::World& world, + ingen::Interface& target, + const FilePath& path, + const boost::optional& parent, + const boost::optional& symbol, + const boost::optional& data) { // Get absolute file path FilePath file_path = path; @@ -670,13 +666,13 @@ Parser::parse_file(ingen::World& world, } boost::optional -Parser::parse_string(ingen::World& world, - ingen::Interface& target, - const std::string& str, - const URI& base_uri, - boost::optional parent, - boost::optional symbol, - boost::optional data) +Parser::parse_string(ingen::World& world, + ingen::Interface& target, + const std::string& str, + const URI& base_uri, + const boost::optional& parent, + const boost::optional& symbol, + const boost::optional& data) { // Load string into model Sord::Model model(*world.rdf_world(), base_uri, SORD_SPO|SORD_PSO, false); -- cgit v1.2.1