commit a82ea3c6e7a65f213e4b87afd6dcfa24b8d48ade parent 251245a0adcdbbda78ce8cb8b2f6a2b55d0accc6 Author: Christos Margiolis <christos@margiolis.net> Date: Thu, 28 May 2020 17:22:37 +0300 added O3, removed inline Diffstat:
27 files changed, 57 insertions(+), 70 deletions(-)
diff --git a/assignment-2.3-operoverloading/Makefile b/assignment-2.3-operoverloading/Makefile @@ -13,7 +13,7 @@ MKDIR_P = mkdir -p CC = g++ CPPFLAGS += -Iinclude -pedantic -CFLAGS += -Wall -std=c++17 +CFLAGS += -Wall -std=c++17 -O3 LDFLAGS += -Llib #LDLIBS += -lm diff --git a/assignment-2.4-inheritance/Makefile b/assignment-2.4-inheritance/Makefile @@ -13,7 +13,7 @@ MKDIR_P = mkdir -p CC = g++ CPPFLAGS += -Iinclude -pedantic -CFLAGS += -Wall -std=c++17 +CFLAGS += -Wall -std=c++17 -O3 LDFLAGS += -Llib #LDLIBS += -lm diff --git a/assignment-2.4-inheritance/bin/inheritance b/assignment-2.4-inheritance/bin/inheritance Binary files differ. diff --git a/assignment-2.4-inheritance/obj/app.o b/assignment-2.4-inheritance/obj/app.o Binary files differ. diff --git a/assignment-2.4-inheritance/obj/appsystem.o b/assignment-2.4-inheritance/obj/appsystem.o Binary files differ. diff --git a/assignment-2.4-inheritance/obj/game.o b/assignment-2.4-inheritance/obj/game.o Binary files differ. diff --git a/assignment-2.4-inheritance/obj/main.o b/assignment-2.4-inheritance/obj/main.o Binary files differ. diff --git a/assignment-2.4-inheritance/obj/manufacturer.o b/assignment-2.4-inheritance/obj/manufacturer.o Binary files differ. diff --git a/assignment-2.4-inheritance/obj/office.o b/assignment-2.4-inheritance/obj/office.o Binary files differ. diff --git a/assignment-2.4-inheritance/obj/review.o b/assignment-2.4-inheritance/obj/review.o Binary files differ. diff --git a/assignment-2.4-inheritance/src/app.h b/assignment-2.4-inheritance/src/app.h @@ -32,18 +32,18 @@ class App void addrevs(const std::vector<Review *> revs) {reviews.insert(reviews.end(), revs.begin(), revs.end());} - inline const std::string& get_name() const {return name;} - inline const std::string& get_os() const {return os;} - inline const Manufacturer get_manf() const {return Manufacturer(*manf);} - inline constexpr const char *get_serialnum() const {return serialnum;} - inline constexpr const std::vector<Review *>& get_revs() const {return reviews;} - inline constexpr int get_price() const {return price;} + const std::string& get_name() const {return name;} + const std::string& get_os() const {return os;} + const Manufacturer get_manf() const {return Manufacturer(*manf);} + constexpr const char *get_serialnum() const {return serialnum;} + constexpr const std::vector<Review *>& get_revs() const {return reviews;} + constexpr int get_price() const {return price;} void set_serialnum(const char *serialnum); - inline void set_name(const std::string& name) {this->name = name;} - inline void set_os(const std::string& os) {this->os = os;} - inline void set_manf(Manufacturer *manf) {this->manf = manf;} - inline void set_price(int price) {this->price = price;} + void set_name(const std::string& name) {this->name = name;} + void set_os(const std::string& os) {this->os = os;} + void set_manf(Manufacturer *manf) {this->manf = manf;} + void set_price(int price) {this->price = price;} virtual void print(std::ostream& stream) const = 0; diff --git a/assignment-2.4-inheritance/src/appsystem.h b/assignment-2.4-inheritance/src/appsystem.h @@ -37,8 +37,8 @@ class AppSystem void removebad (Manufacturer *man); void removebad (const char *manfname); - inline constexpr const std::vector<App *>& get_apps() const {return apps;} - inline constexpr const std::vector<Manufacturer *>& get_manfs() const {return manfs;} + constexpr const std::vector<App *>& get_apps() const {return apps;} + constexpr const std::vector<Manufacturer *>& get_manfs() const {return manfs;} const std::vector<Office *> get_freeapps() const; const std::vector<Game *> get_goodgames() const; diff --git a/assignment-2.4-inheritance/src/game.h b/assignment-2.4-inheritance/src/game.h @@ -16,11 +16,11 @@ class Game: public App const std::string& genre, bool online); Game(const Game& g); - inline const std::string get_genre() const {return genre;} - inline constexpr bool get_online() const {return online;} - inline void set_genre(const std::string& genre) {this->genre = genre;} - inline void set_online(bool online) {this->online = online;} - virtual void print(std::ostream& stream) const override; + const std::string get_genre() const {return genre;} + constexpr bool get_online() const {return online;} + void set_genre(const std::string& genre) {this->genre = genre;} + void set_online(bool online) {this->online = online;} + void print(std::ostream& stream) const override; }; #endif /* GAME_H */ diff --git a/assignment-2.4-inheritance/src/manufacturer.h b/assignment-2.4-inheritance/src/manufacturer.h @@ -19,13 +19,13 @@ class Manufacturer Manufacturer(const Manufacturer& m); ~Manufacturer(); - inline const std::string& get_email() const {return email;} - inline constexpr const char *get_serialnum() const {return serialnum;} - inline constexpr const char *get_name() const {return name;} + const std::string& get_email() const {return email;} + constexpr const char *get_serialnum() const {return serialnum;} + constexpr const char *get_name() const {return name;} void set_serialnum(const char *serialnum); void set_name(const char *name); - inline void set_email(const std::string& email) {this->email = email;} + void set_email(const std::string& email) {this->email = email;} private: char *convstr(const char *str); diff --git a/assignment-2.4-inheritance/src/office.h b/assignment-2.4-inheritance/src/office.h @@ -18,7 +18,7 @@ class Office: public App const std::vector<std::string> get_exts() const {return extensions;} void set_exts(const std::vector<std::string>& extensions); - virtual void print(std::ostream& stream) const override; + void print(std::ostream& stream) const override; }; #endif /* OFFICE_H */ diff --git a/assignment-2.4-inheritance/src/review.h b/assignment-2.4-inheritance/src/review.h @@ -17,14 +17,14 @@ class Review const std::string& comment); Review(const Review& r); - inline const std::string& get_username() const {return username;} - inline const std::string& get_comment() const {return comment;} - inline constexpr int get_stars() const {return stars;} + const std::string& get_username() const {return username;} + const std::string& get_comment() const {return comment;} + constexpr int get_stars() const {return stars;} - inline void set_stars(int stars) {this->stars = stars;} - inline void set_username(const std::string& username) + void set_stars(int stars) {this->stars = stars;} + void set_username(const std::string& username) {this->username = username;} - inline void set_comment(const std::string& comment) + void set_comment(const std::string& comment) {this->comment = comment;} }; diff --git a/assignment-2.5-spreadsheets/Makefile b/assignment-2.5-spreadsheets/Makefile @@ -13,7 +13,7 @@ MKDIR_P = mkdir -p CC = g++ CPPFLAGS += -Iinclude -pedantic -CFLAGS += -Wall -std=c++17 +CFLAGS += -Wall -std=c++17 -O3 LDFLAGS += -Llib #LDLIBS += -lm diff --git a/assignment-2.5-spreadsheets/bin/spreadsheets b/assignment-2.5-spreadsheets/bin/spreadsheets Binary files differ. diff --git a/assignment-2.5-spreadsheets/obj/datahandler.o b/assignment-2.5-spreadsheets/obj/datahandler.o Binary files differ. diff --git a/assignment-2.5-spreadsheets/obj/errlog.o b/assignment-2.5-spreadsheets/obj/errlog.o Binary files differ. diff --git a/assignment-2.5-spreadsheets/obj/main.o b/assignment-2.5-spreadsheets/obj/main.o Binary files differ. diff --git a/assignment-2.5-spreadsheets/obj/xstring.o b/assignment-2.5-spreadsheets/obj/xstring.o Binary files differ. diff --git a/assignment-2.5-spreadsheets/src/course.h b/assignment-2.5-spreadsheets/src/course.h @@ -3,18 +3,13 @@ #include "xstring.h" -class Course +struct Course { - private: lab::xstring code; lab::xstring name; - public: Course(const lab::xstring& code, const lab::xstring& name) :code(code), name(name) {} - - inline constexpr const lab::xstring& get_code() const {return code;} - inline constexpr const lab::xstring& get_name() const {return name;} }; #endif /* COURSE_H */ diff --git a/assignment-2.5-spreadsheets/src/datahandler.cpp b/assignment-2.5-spreadsheets/src/datahandler.cpp @@ -124,17 +124,17 @@ DataHandler::miss(lab::xstring id, lab::xstring code, float grade) { bool found = false; for (const auto& grd : grds) - if (grd.first->get_code() == eqvs[code]) + if (grd.first->code == eqvs[code]) found = true; if (!found) { missing.push_back(id + ";" + - studs[id]->get_lname() + ";" + - studs[id]->get_fname() + ";" + - courses[eqvs[code]]->get_code() + ";" + - courses[eqvs[code]]->get_name() + ";" + + studs[id]->lname + ";" + + studs[id]->fname + ";" + + courses[eqvs[code]]->code + ";" + + courses[eqvs[code]]->name + ";" + eqvs[code] + ";" + - courses[code]->get_name() + ";" + + courses[code]->name + ";" + lab::to_xstr<float>("%.1f", grade)); misscount++; } diff --git a/assignment-2.5-spreadsheets/src/errlog.h b/assignment-2.5-spreadsheets/src/errlog.h @@ -19,8 +19,6 @@ class ErrLog ErrLog(); void write(ErrType type, const lab::xstring& s) const; - - private: }; #endif /* ERRLOG_H */ diff --git a/assignment-2.5-spreadsheets/src/student.h b/assignment-2.5-spreadsheets/src/student.h @@ -3,22 +3,16 @@ #include "xstring.h" -class Student +struct Student { - private: lab::xstring id; lab::xstring lname; lab::xstring fname; - public: Student(const lab::xstring& id, const lab::xstring& lname, const lab::xstring& fname) :id(id), lname(lname), fname(fname) {} - - inline constexpr const lab::xstring& get_id() const {return id;} - inline constexpr const lab::xstring& get_lname() const {return lname;} - inline constexpr const lab::xstring& get_fname() const {return fname;} }; #endif /* STUDENT_H */ diff --git a/assignment-2.5-spreadsheets/src/xstring.h b/assignment-2.5-spreadsheets/src/xstring.h @@ -27,29 +27,29 @@ class xstring xstring& operator+= (const xstring& s); xstring& operator+= (const char *s); xstring& operator+= (char c); - inline constexpr bool operator== (const xstring& s) const + constexpr bool operator== (const xstring& s) const {return std::strcmp(this->str, s.str) == 0;} - inline constexpr bool operator== (const char *s) const + constexpr bool operator== (const char *s) const {return std::strcmp(this->str, s) == 0;} - inline constexpr bool operator!= (const xstring& s) const + constexpr bool operator!= (const xstring& s) const {return std::strcmp(this->str, s.str) != 0;} - inline constexpr bool operator!= (const char *s) const + constexpr bool operator!= (const char *s) const {return std::strcmp(this->str, s) != 0;} - inline constexpr bool operator< (const xstring& s) const + constexpr bool operator< (const xstring& s) const {return std::strcmp(this->str, s.str) < 0;} - inline constexpr bool operator< (const char *s) const + constexpr bool operator< (const char *s) const {return std::strcmp(this->str, s) < 0;} - inline constexpr bool operator<= (const xstring& s) const + constexpr bool operator<= (const xstring& s) const {return std::strcmp(this->str, s.str) <= 0;} - inline constexpr bool operator<= (const char *s) const + constexpr bool operator<= (const char *s) const {return std::strcmp(this->str, s) <= 0;} - inline constexpr bool operator> (const xstring& s) const + constexpr bool operator> (const xstring& s) const {return std::strcmp(this->str, s.str) > 0;} - inline constexpr bool operator> (const char *s) const + constexpr bool operator> (const char *s) const {return std::strcmp(this->str, s) > 0;} - inline constexpr bool operator>= (const xstring& s) const + constexpr bool operator>= (const xstring& s) const {return std::strcmp(this->str, s.str) >= 0;} - inline constexpr bool operator>= (const char *s) const + constexpr bool operator>= (const char *s) const {return std::strcmp(this->str, s) >= 0;} char& operator[] (std::size_t i) const; friend std::ostream& operator<< (std::ostream& stream, const xstring& s); @@ -66,17 +66,17 @@ class xstring void clear(); bool find(const xstring& s) const; bool find(const char *s) const; - inline constexpr char *cstr() const {return str;} - inline constexpr char& front() const {return str[0];} - inline constexpr char& back() const + constexpr char *cstr() const {return str;} + constexpr char& front() const {return str[0];} + constexpr char& back() const {return (!this->empty()) ? str[len-1] : str[0];}; - inline constexpr bool empty() const {return len == 0;} - inline constexpr std::size_t length() const {return std::strlen(str);} + constexpr bool empty() const {return len == 0;} + constexpr std::size_t length() const {return std::strlen(str);} private: void resize(std::size_t n); char *conv(const char *s) const; - inline constexpr bool strempty(const char *s) const + constexpr bool strempty(const char *s) const {return std::strlen(s) == 0;} };