Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

few cosmetic changes and with C++17 no need to explictly define copy … #607

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/xgraph/xgraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,11 +297,11 @@ void XGR_Screen::set_resolution(int width, int height){
create_surfaces(width, height);
}

const float XGR_Screen::get_screen_scale_x() {
float XGR_Screen::get_screen_scale_x() const {
return screen_scale_x;
}

const float XGR_Screen::get_screen_scale_y() {
float XGR_Screen::get_screen_scale_y() const {
return screen_scale_y;
}

Expand Down Expand Up @@ -343,7 +343,7 @@ void XGR_Screen::set_is_scaled_renderer(bool is_scaled_renderer)
this->is_scaled_renderer = is_scaled_renderer;
}

const bool XGR_Screen::get_is_scaled_renderer()
bool XGR_Screen::get_is_scaled_renderer() const
{
return this->is_scaled_renderer;
}
Expand Down
6 changes: 3 additions & 3 deletions lib/xgraph/xgraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ struct XGR_Screen
void set_fullscreen(bool fullscreen);
void set_resolution(int width, int height);
void set_is_scaled_renderer(bool is_scaled_renderer);
const bool get_is_scaled_renderer();
const float get_screen_scale_x();
const float get_screen_scale_y();
bool get_is_scaled_renderer() const;
float get_screen_scale_x() const;
float get_screen_scale_y() const;

void setpixel(int x,int y,int col);
int getpixel(int x,int y);
Expand Down
4 changes: 2 additions & 2 deletions lib/xsound/ogg_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ static long stream_tell_func (void *datasource) {
return ftell(file);
}

OggStream::OggStream(const std::string &fname) {
_file = fopen(fname.c_str(), "rb");
OggStream::OggStream(const std::string_view fname) {
_file = fopen(fname.data(), "rb");
Copy link
Contributor

@caiiiycuk caiiiycuk Aug 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why data is more preferable then c_str()?

Copy link
Contributor Author

@devnexen devnexen Aug 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

simply because there is no such things with string_view :-) it s chunk of bytes that s how it gains perf over a traditional std string, no need allocation.

https://en.cppreference.com/w/cpp/string/basic_string_view

if (_file == NULL) {
perror("fopen");
throw std::runtime_error("cannot open file");
Expand Down
4 changes: 2 additions & 2 deletions lib/xsound/ogg_stream.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef __SAMPLE_CLUNK_OGG_STREAM_H__
#define __SAMPLE_CLUNK_OGG_STREAM_H__

#include <string>
#include <string_view>
#include <cstring>
#include <stdio.h>
#include <clunk/stream.h>
Expand All @@ -18,7 +18,7 @@ namespace clunk {

class OggStream : public clunk::Stream {
public:
OggStream(const std::string &fname);
OggStream(const std::string_view fname);
void rewind();
bool read(clunk::Buffer &data, unsigned hint);
~OggStream();
Expand Down
16 changes: 1 addition & 15 deletions src/3d/3d_math.h
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@ struct DBV {

DBV();
DBV(double u,double v,double t);
DBV(const DBV& v);
DBV(const Vector& v);

double operator [](unsigned int i) const { return ((double*)this)[i % 3]; }
Expand Down Expand Up @@ -408,7 +407,6 @@ struct DBM {

// Creates I
DBM();
DBM(const DBM& m);
DBM(double a0,double a1,double a2,
double a3,double a4,double a5,
double a6,double a7,double a8);
Expand Down Expand Up @@ -867,12 +865,6 @@ inline DBV::DBV(double u,double v,double t)
y = v;
z = t;
}
inline DBV::DBV(const DBV& v)
{
x = v.x;
y = v.y;
z = v.z;
}
inline DBV::DBV(const Vector& v)
{
x = v.x;
Expand Down Expand Up @@ -1159,12 +1151,6 @@ inline DBM::DBM()
a[3] = 0; a[4] = 1; a[5] = 0;
a[6] = 0; a[7] = 0; a[8] = 1;
}
inline DBM::DBM(const DBM& m)
{
a[0] = m[0]; a[1] = m[1]; a[2] = m[2];
a[3] = m[3]; a[4] = m[4]; a[5] = m[5];
a[6] = m[6]; a[7] = m[7]; a[8] = m[8];
}
inline DBM::DBM(double a0,double a1,double a2,
double a3,double a4,double a5,
double a6,double a7,double a8)
Expand Down Expand Up @@ -1346,4 +1332,4 @@ inline DBM DBM::operator- (double w) const
return m;
}

#endif
#endif