Skip to content

Commit 9ed8323

Browse files
author
Pierre-Antoine Lacaze
committed
Changed my mind about defaulting to compile time reduction
1 parent c41eeaa commit 9ed8323

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ include(SigslotUtils)
99
### options
1010
option(SIGSLOT_COMPILE_EXAMPLES "Compile optional exemples" ON)
1111
option(SIGSLOT_COMPILE_TESTS "Compile tests" ON)
12-
option(SIGSLOT_DISABLE_CODE_SIZE_REDUCTION "Do not try to reduce code size and compilation time" OFF)
12+
option(SIGSLOT_REDUCE_COMPILE_TIME "Attempt at reducing code size and compilation time" OFF)
1313

1414
### sigslot library
1515
add_library(sigslot INTERFACE)
@@ -19,7 +19,7 @@ target_include_directories(sigslot INTERFACE
1919
)
2020

2121
target_compile_definitions(sigslot INTERFACE
22-
$<$<BOOL:${SIGSLOT_DISABLE_CODE_SIZE_REDUCTION}>:SIGSLOT_DISABLE_CODE_SIZE_REDUCTION>)
22+
$<$<BOOL:${SIGSLOT_REDUCE_COMPILE_TIME}>:SIGSLOT_REDUCE_COMPILE_TIME>)
2323
set_target_properties(sigslot PROPERTIES EXPORT_NAME Sigslot)
2424
sigslot_set_properties(sigslot INTERFACE)
2525
add_library(Pal::Sigslot ALIAS sigslot)

example/lambdas.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
#include <cstdio>
33

44
/*
5-
* This example is meant to test compilation time as well as object size
6-
* when a lot of unique callables get connected to a signal.
7-
* This example motivated the introduction of a REDUCE_CODE_SIZE cmake option.
5+
* This example is meant to test compilation time as well as object size when a
6+
* lot of unique callables get connected to a signal.
7+
* This example motivated the introduction of a SOCUTE_REDUCE_COMPILE_TIME cmake option.
88
*/
99

1010
#define LAMBDA4() sig.connect([](int) { puts("lambda\n"); });

include/sigslot/signal.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -212,15 +212,15 @@ T& cow_write(copy_on_write<T> &v) {
212212
* - Not exception safe,
213213
* - Allocates a separate control block, and will thus make the code slower.
214214
*/
215-
#ifdef SIGSLOT_DISABLE_CODE_SIZE_REDUCTION
215+
#ifdef SIGSLOT_REDUCE_COMPILE_TIME
216216
template<typename B, typename D, typename ...Arg>
217217
inline std::shared_ptr<B> make_shared(Arg && ... arg) {
218-
return std::static_pointer_cast<B>(std::make_shared<D>(std::forward<Arg>(arg)...));
218+
return std::shared_ptr<B>(static_cast<B*>(new D(std::forward<Arg>(arg)...)));
219219
}
220220
#else
221221
template<typename B, typename D, typename ...Arg>
222222
inline std::shared_ptr<B> make_shared(Arg && ... arg) {
223-
return std::shared_ptr<B>(static_cast<B*>(new D(std::forward<Arg>(arg)...)));
223+
return std::static_pointer_cast<B>(std::make_shared<D>(std::forward<Arg>(arg)...));
224224
}
225225
#endif
226226

readme.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ No compilation or installation is required, just include `sigslot/signal.hpp` an
1818

1919
A CMake build file is supplied for installation purpose and generating a CMake import module. It is also required for examples and tests, which optionally depend on Qt5 and Boost for adapters unit tests.
2020

21-
A configuration option `SIGSLOT_DISABLE_CODE_SIZE_REDUCTION` is available at configuration time.
22-
When activated, it disables any attempt at reducing code bloat by avoiding heavy template instantiations resulting from calls to `std::make_shared`.
23-
This option is off by default, but can be activated for those who with to favor code efficiency at the expanse of compilation times.
21+
A configuration option `SIGSLOT_REDUCE_COMPILE_TIME` is available at configuration time.
22+
When activated, it attempts to reduce code bloat by avoiding heavy template instantiations resulting from calls to `std::make_shared`.
23+
This option is off by default, but can be activated for those who with to favor code size and compilation time at the expanse of slightly less efficient code.
2424

2525
Installation may be done using the following instructions from the root directory:
2626

2727
```sh
2828
mkdir build && cd build
29-
cmake .. -DSIGSLOT_DISABLE_CODE_SIZE_REDUCTION=ON -DCMAKE_INSTALL_PREFIX=~/local
29+
cmake .. -DSIGSLOT_REDUCE_COMPILE_TIME=ON -DCMAKE_INSTALL_PREFIX=~/local
3030
cmake --build . --target install
3131

3232
# If you want to compile examples:

0 commit comments

Comments
 (0)