Skip to content

Commit 07829cd

Browse files
committed
minor improvements
1 parent 4ed9d33 commit 07829cd

8 files changed

Lines changed: 33 additions & 25 deletions

File tree

examples/ActorThread/HelloWorld/GNUmakefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
ifeq ($(DEBUG), 1)
22
BUILD_DIR := debug
3-
CXXFLAGS += -O0 -g3 -Wno-misleading-indentation -Wno-unknown-warning-option
3+
CXXFLAGS := -O0 -g3 $(CXXFLAGS)
44
else
55
BUILD_DIR := release
6-
CXXFLAGS += -O2
6+
CXXFLAGS := -O2 $(CXXFLAGS)
77
endif
88

99
PATH_BIN := $(BUILD_DIR)/application

examples/ActorThread/MyLib/GNUmakefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
ifeq ($(DEBUG), 1)
22
BUILD_DIR := debug
3-
CXXFLAGS += -O0 -g3 -Wno-misleading-indentation -Wno-unknown-warning-option
3+
CXXFLAGS := -O0 -g3 $(CXXFLAGS)
44
else
55
BUILD_DIR := release
6-
CXXFLAGS += -O2
6+
CXXFLAGS := -O2 $(CXXFLAGS)
77
endif
88

99
OUT_LIB := MyLib.a

examples/ActorThread/MyLibClient/GNUmakefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
ifeq ($(DEBUG), 1)
22
BUILD_DIR := debug
3-
CXXFLAGS += -O0 -g3 -Wno-misleading-indentation -Wno-unknown-warning-option
3+
CXXFLAGS := -O0 -g3 $(CXXFLAGS)
44
else
55
BUILD_DIR := release
6-
CXXFLAGS += -O2
6+
CXXFLAGS := -O2 $(CXXFLAGS)
77
endif
88

99
PATH_BIN := $(BUILD_DIR)/application

examples/ActorThread/Test/GNUmakefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
ifeq ($(DEBUG), 1)
22
BUILD_DIR := debug
3-
CXXFLAGS += -O0 -g3 -Wno-misleading-indentation -Wno-unknown-warning-option
3+
CXXFLAGS := -O0 -g3 $(CXXFLAGS)
44
else
55
BUILD_DIR := release
6-
CXXFLAGS += -O2 -g3
6+
CXXFLAGS := -O2 $(CXXFLAGS)
77
endif
88

99
PATH_BIN := $(BUILD_DIR)/application

examples/ActorThread/Test/src/Application.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,7 @@ template <> void Application::onMessage(Mpsc& msg)
243243
auto sc2 = count_mpsc2 - count_mpsc2_lap;
244244
auto elapsed_sc_avg = (mpsc_elapsed_sc1 + mpsc_elapsed_sc2) / 2;
245245

246-
double min_msgs = std::min(std::min(std::min(std::min(std::min(
247-
count_mpsc1, count_mpsc2), count_mpsc1_lap), count_mpsc2_lap), sc1), sc2);
246+
double min_msgs = std::min(std::min(std::min(count_mpsc1, count_mpsc2), count_mpsc1_lap), count_mpsc2_lap);
248247

249248
double r_2p1c_p = 1.0 * std::max(count_mpsc1, count_mpsc2) / std::min(count_mpsc1, count_mpsc2);
250249
double r_2p1c_c = 1.0 * std::max(count_mpsc1_lap, count_mpsc2_lap) / std::min(count_mpsc1_lap, count_mpsc2_lap);

include/sys++/ActorThread.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ template <typename Runnable> class ActorThread
137137
void onStart() {}
138138
void onStop() {}
139139

140+
std::thread::id threadID() const { return id; }
141+
140142
/* the active object may use this family of methods to perform the callbacks onto connected clients */
141143

142144
template <typename Any> inline static void publish(Any msg)

include/sys++/String.hpp

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,49 +12,54 @@
1212
#include <algorithm>
1313
#include <sstream>
1414

15+
#ifndef VA_STR
1516
#define VA_STR(x) static_cast<std::ostringstream&>(std::ostringstream().flush() << x).str()
17+
#endif
1618

1719
struct String // a "namespace" not requiring a cpp nor inlining to avoid "unused function" warnings
1820
{
19-
static std::string& tolower(std::string& str)
21+
static void tolower(std::string& str)
2022
{
2123
std::transform(str.begin(), str.end(), str.begin(), ::tolower);
22-
return str;
2324
}
2425

25-
static std::string& toupper(std::string& str)
26+
static void toupper(std::string& str)
2627
{
2728
std::transform(str.begin(), str.end(), str.begin(), ::toupper);
28-
return str;
2929
}
3030

31-
static std::string& ltrim(std::string& str)
31+
static void ltrim(std::string& str)
3232
{
3333
std::string::iterator i = str.begin();
3434
while (i != str.end()) if (!std::isspace(*i)) break; else ++i;
3535
str.erase(str.begin(), i);
36-
return str;
3736
}
3837

39-
static std::string& rtrim(std::string& str)
38+
static void rtrim(std::string& str)
4039
{
4140
std::string::iterator i = str.end();
4241
while (i != str.begin()) if (!std::isspace(*(--i))) { ++i; break; }
4342
str.erase(i, str.end());
44-
return str;
4543
}
4644

47-
static std::string& trim(std::string& str)
45+
static void trim(std::string& str)
4846
{
49-
return ltrim(rtrim(str));
47+
rtrim(str);
48+
ltrim(str);
49+
}
50+
51+
static std::string trimmed(std::string str)
52+
{
53+
trim(str);
54+
return str;
5055
}
5156

5257
static std::string right(const std::string& str, std::string::size_type count)
5358
{
5459
return str.substr(str.size() - std::min(count, str.size()));
5560
}
5661

57-
static std::string& replaceAll(std::string& str, const std::string& sWhat, const std::string& sWith)
62+
static void replaceAll(std::string& str, const std::string& sWhat, const std::string& sWith)
5863
{
5964
std::string::size_type lookHere = 0;
6065
std::string::size_type foundHere;
@@ -63,7 +68,6 @@ struct String // a "namespace" not requiring a cpp nor inlining to avoid "unused
6368
str.replace(foundHere, sWhat.size(), sWith);
6469
lookHere = foundHere + sWith.size();
6570
}
66-
return str;
6771
}
6872

6973
template <typename T> static void split(const std::string& str, const char delimiter, T& result, bool trimmed = true)

posix.mk

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,14 @@ WARNFLAGS ?= -Wall -Wextra -pedantic -Wconversion -Wsign-conversion -Wsign-promo
4040
-Wpointer-arith -Wnon-virtual-dtor -Woverloaded-virtual -Wshadow -Wundef -Wmissing-include-dirs
4141

4242
CXXFLAGS += $(ARCHFLAGS) $(WARNFLAGS)
43-
INCLUDES += $(foreach dir,$(SUBPRJS),-I$(dir)/include)
44-
LIBS += $(foreach dir,$(SUBPRJS),$(wildcard $(dir)/$(BUILD_DIR)/*.a))
43+
44+
CXXFLAGS := $(filter-out $(SKIPFLAGS), $(CXXFLAGS)) # allow skipping particular warnings
45+
46+
INCLUDES := $(foreach dir,$(SUBPRJS),-I$(dir)/include) $(INCLUDES)
47+
LIBS := $(foreach dir,$(SUBPRJS),$(wildcard $(dir)/$(BUILD_DIR)/*.a)) $(LIBS)
4548

4649
ifdef OUT_LIB
47-
INCLUDES += -Iinclude
50+
INCLUDES := -Iinclude $(INCLUDES)
4851
endif
4952

5053
ifndef MK_NOHL

0 commit comments

Comments
 (0)