Skip to content

Commit 4fa0bc4

Browse files
committed
Core (Benchmarks): Use std::string_view for string arguments.
1 parent 4ebf03e commit 4fa0bc4

3 files changed

Lines changed: 15 additions & 6 deletions

File tree

libvisual/tools/benchmarks/actor_bench.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,28 @@
33
#include <iostream>
44
#include <memory>
55
#include <stdexcept>
6+
#include <string>
7+
#include <string_view>
68
#include <cstdlib>
79

10+
using namespace std::string_literals;
11+
812
namespace {
913

1014
class ActorBench
1115
: public LV::Tools::Benchmark
1216
{
1317
public:
1418

15-
ActorBench (std::string const& actor_name, unsigned int width, unsigned height, VisVideoDepth depth, bool forced_depth)
19+
ActorBench (std::string_view actor_name, unsigned int width, unsigned height, VisVideoDepth depth, bool forced_depth)
1620
: Benchmark { "ActorBench" }
1721
, m_actor { LV::Actor::load (actor_name) }
1822
{
1923
(void)width;
2024
(void)height;
2125

2226
if (!m_actor) {
23-
throw std::invalid_argument ("Cannot load actor '" + actor_name);
27+
throw std::invalid_argument {"Cannot load actor '"s + std::string {actor_name}};
2428
}
2529

2630
m_actor->realize ();

libvisual/tools/benchmarks/benchmark.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#define _LV_TOOLS_BENCHMARK_HPP
33

44
#include <string>
5+
#include <string_view>
56

67
namespace LV {
78
namespace Tools {
@@ -22,8 +23,8 @@ namespace LV {
2223

2324
protected:
2425

25-
explicit Benchmark (std::string const& name)
26-
: m_name (name)
26+
explicit Benchmark (std::string_view name)
27+
: m_name {name}
2728
{}
2829

2930
private:

libvisual/tools/benchmarks/morph_bench.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,25 @@
33
#include <iostream>
44
#include <memory>
55
#include <stdexcept>
6+
#include <string>
7+
#include <string_view>
68
#include <cstdlib>
79

810
namespace {
911

12+
using namespace std::string_literals;
13+
1014
class MorphBench
1115
: public LV::Tools::Benchmark
1216
{
1317
public:
1418

15-
MorphBench (std::string const& morph_name, unsigned int width, unsigned int height, VisVideoDepth depth)
19+
MorphBench (std::string_view morph_name, unsigned int width, unsigned int height, VisVideoDepth depth)
1620
: Benchmark { "MorphBench" }
1721
, m_morph { LV::Morph::load (morph_name) }
1822
{
1923
if (!m_morph) {
20-
throw std::invalid_argument ("Cannot load morph " + morph_name);
24+
throw std::invalid_argument {"Cannot load morph "s + std::string {morph_name}};
2125
}
2226

2327
m_morph->realize ();

0 commit comments

Comments
 (0)