Skip to content

Commit 80e4871

Browse files
committed
Replace use of const std::string & to string_view
1 parent 0065adb commit 80e4871

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

examples/Ur5WithSystems.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,16 @@ static void updateOrtho(float zoom) {
9494
}
9595

9696
static std::shared_ptr<coal::ConvexBase>
97-
loadConvexMeshFromFile(const std::string &filename) {
97+
loadConvexMeshFromFile(std::string_view filename) {
9898
coal::NODE_TYPE bv_type = coal::BV_AABB;
9999
coal::MeshLoader load{bv_type};
100-
coal::BVHModelPtr_t bvh = load.load(filename);
100+
coal::BVHModelPtr_t bvh = load.load(std::string{filename});
101101
bvh->buildConvexHull(true, "Qt");
102102
return bvh->convex;
103103
}
104104

105105
static pin::GeometryObject
106-
loadGeomObjFromFile(const char *name, const std::string &filename,
106+
loadGeomObjFromFile(const char *name, std::string_view filename,
107107
pin::SE3 pl = pin::SE3::Identity()) {
108108
auto convex = loadConvexMeshFromFile(filename);
109109
Eigen::Vector3d scale;

src/candlewick/utils/VideoRecorder.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ namespace media {
5050
AVFrame *tmpFrame = nullptr;
5151
AVPacket *packet = nullptr;
5252

53-
VideoRecorderImpl(int width, int height, const std::string &filename,
53+
VideoRecorderImpl(int width, int height, std::string_view filename,
5454
VideoRecorder::Settings settings);
5555

5656
VideoRecorderImpl(const VideoRecorderImpl &) = delete;
@@ -96,7 +96,7 @@ namespace media {
9696
}
9797

9898
VideoRecorderImpl::VideoRecorderImpl(int width, int height,
99-
const std::string &filename,
99+
std::string_view filename,
100100
VideoRecorder::Settings settings)
101101
: m_width(width), m_height(height) {
102102

@@ -111,7 +111,7 @@ namespace media {
111111
}
112112

113113
int ret = avformat_alloc_output_context2(&formatContext, nullptr, nullptr,
114-
filename.c_str());
114+
filename.data());
115115
char errbuf[AV_ERROR_MAX_STRING_SIZE]{0};
116116
if (ret < 0) {
117117
av_strerror(ret, errbuf, AV_ERROR_MAX_STRING_SIZE);
@@ -150,7 +150,7 @@ namespace media {
150150
terminate_with_message("Couldn't open codec: %s", errbuf);
151151
}
152152

153-
ret = avio_open(&formatContext->pb, filename.c_str(), AVIO_FLAG_WRITE);
153+
ret = avio_open(&formatContext->pb, filename.data(), AVIO_FLAG_WRITE);
154154
if (ret < 0) {
155155
av_strerror(ret, errbuf, AV_ERROR_MAX_STRING_SIZE);
156156
terminate_with_message("Couldn't open output stream: %s", errbuf);
@@ -229,18 +229,18 @@ namespace media {
229229
VideoRecorder &VideoRecorder::operator=(VideoRecorder &&) noexcept = default;
230230

231231
VideoRecorder::VideoRecorder(Uint32 width, Uint32 height,
232-
const std::string &filename, Settings settings)
232+
std::string_view filename, Settings settings)
233233
: _width(width), _height(height) {
234234
this->settings = settings;
235235
this->open(width, height, filename);
236236
}
237237

238238
VideoRecorder::VideoRecorder(Uint32 width, Uint32 height,
239-
const std::string &filename)
239+
std::string_view filename)
240240
: VideoRecorder(width, height, filename, Settings{}) {}
241241

242242
void VideoRecorder::open(Uint32 width, Uint32 height,
243-
const std::string &filename) {
243+
std::string_view filename) {
244244
if (_impl)
245245
terminate_with_message("Recording stream already open.");
246246

src/candlewick/utils/VideoRecorder.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ namespace media {
3737
VideoRecorder(VideoRecorder &&) noexcept;
3838
VideoRecorder &operator=(VideoRecorder &&) noexcept;
3939

40-
void open(Uint32 width, Uint32 height, const std::string &filename);
40+
void open(Uint32 width, Uint32 height, std::string_view filename);
4141

4242
bool isRecording() const { return _impl != nullptr; }
4343

@@ -50,10 +50,10 @@ namespace media {
5050
///
5151
/// \note If the settings' output dimensions are not set, they will
5252
/// automatically be set to be the input's dimensions.
53-
VideoRecorder(Uint32 width, Uint32 height, const std::string &filename,
53+
VideoRecorder(Uint32 width, Uint32 height, std::string_view filename,
5454
Settings settings);
5555

56-
VideoRecorder(Uint32 width, Uint32 height, const std::string &filename);
56+
VideoRecorder(Uint32 width, Uint32 height, std::string_view filename);
5757

5858
Uint32 frameCounter() const;
5959

0 commit comments

Comments
 (0)