Skip to content

Commit 3ade58e

Browse files
committed
Simplify namespaces and cleanup redundant code.
Updated namespace usage to remove unnecessary prefixes, streamlined variable declarations, and improved code readability. Removed unused comments and applied minor refactoring for better maintenance and clarity.
1 parent 99daf5d commit 3ade58e

10 files changed

Lines changed: 29 additions & 36 deletions

File tree

‎ElementsExamples/src/program/SimpleProgram.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class SimpleProgram final : public Program {
6464

6565
log.info("This Works");
6666

67-
Elements::nanoSleep(4);
67+
nanoSleep(4);
6868

6969
std::cout << "This Works too!" << std::endl;
7070

‎ElementsKernel/src/Lib/ProgramManager.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,8 @@ void ProgramManager::bootstrapEnvironment(char* arg0) {
388388

389389
// insert local parent dir if it is not already
390390
// the first one of the list
391-
const Path::Item this_parent_path = canonical(m_program_path.parent_path());
392-
if (local_search_paths[0] != this_parent_path) {
391+
if (const Path::Item this_parent_path = canonical(m_program_path.parent_path());
392+
local_search_paths[0] != this_parent_path) {
393393
const auto b = local_search_paths.begin();
394394
local_search_paths.insert(b, this_parent_path);
395395
}

‎ElementsKernel/src/Lib/Real.cpp‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,19 @@ bool almostEqual2sComplement(const float& left, const float& right, const int& m
4141
using std::int32_t;
4242
using std::uint32_t;
4343

44-
// int a_int = *(int*)&a;
4544
int32_t a_int;
4645
std::memcpy(&a_int, &left, sizeof(int32_t));
4746
// Make a_int lexicographically ordered as a twos-complement int
4847
if (a_int < 0) {
4948
a_int = static_cast<int32_t>(0x80000000 - static_cast<uint32_t>(a_int));
5049
}
5150
// Make b_int lexicographically ordered as a twos-complement int
52-
// int b_int = *(int*)&b;
5351
int32_t b_int;
5452
std::memcpy(&b_int, &right, sizeof(int32_t));
5553
if (b_int < 0) {
5654
b_int = static_cast<int32_t>(0x80000000 - static_cast<uint32_t>(b_int));
5755
}
58-
int32_t int_diff = abs(a_int - b_int);
59-
if (int_diff <= max_ulps && -max_ulps <= int_diff) {
56+
if (int32_t int_diff = abs(a_int - b_int); int_diff <= max_ulps && -max_ulps <= int_diff) {
6057
return true;
6158
}
6259
return false;
@@ -67,23 +64,19 @@ bool almostEqual2sComplement(const double& left, const double& right, const int&
6764
using std::int64_t;
6865
using std::uint64_t;
6966

70-
// long long a_int = *(long long*)&a;
71-
7267
int64_t a_int;
7368
std::memcpy(&a_int, &left, sizeof(a_int));
7469
// Make a_int lexicographically ordered as a twos-complement int
7570
if (a_int < 0) {
7671
a_int = static_cast<int64_t>(0x8000000000000000LL - static_cast<uint64_t>(a_int));
7772
}
7873
// Make b_int lexicographically ordered as a twos-complement int
79-
// long long b_int = *(long long*)&b;
8074
int64_t b_int;
8175
std::memcpy(&b_int, &right, sizeof(b_int));
8276
if (b_int < 0) {
8377
b_int = static_cast<int64_t>(0x8000000000000000LL - static_cast<uint64_t>(b_int));
8478
}
85-
int64_t int_diff = abs(a_int - b_int);
86-
if (int_diff <= max_ulps && -max_ulps <= int_diff) {
79+
if (int64_t int_diff = abs(a_int - b_int); int_diff <= max_ulps && -max_ulps <= int_diff) {
8780
return true;
8881
}
8982
return false;

‎ElementsKernel/src/Lib/System.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ unsigned long getProcedureByName(ImageHandle handle, const string& name, Creator
146146
/// Retrieve last error code
147147
unsigned long getLastError() {
148148
// convert errno (int) to unsigned long
149-
return static_cast<unsigned long>(static_cast<unsigned int>(errno));
149+
return static_cast<unsigned int>(errno);
150150
}
151151

152152
/// Retrieve last error code as string
@@ -161,7 +161,7 @@ string getErrorString(const unsigned long error) {
161161
char* cerrString(nullptr);
162162
// Remember: for linux dl* routines must be handled differently!
163163
if (error == 0xAFFEDEAD) {
164-
cerrString = reinterpret_cast<char*>(dlerror());
164+
cerrString = dlerror();
165165
if (nullptr == cerrString) {
166166
cerrString = std::strerror(static_cast<int>(error));
167167
}
@@ -213,7 +213,7 @@ string typeinfoName(const char* class_name) {
213213
/// substitute ', ' with ','
214214
string::size_type pos = result.find(", ");
215215
while (string::npos != pos) {
216-
result.replace(pos, static_cast<string::size_type>(2), ",");
216+
result.replace(pos, 2, ",");
217217
pos = result.find(", ");
218218
}
219219
}

‎ElementsKernel/tests/src/GLibCxxParallel_test.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ BOOST_AUTO_TEST_CASE(GLibCxxParallelWorks) {
3333

3434
constexpr std::size_t val_size_t = 1000;
3535

36-
std::vector<double> vals(val_size_t, 1.0);
36+
std::vector vals(val_size_t, 1.0);
3737

3838
std::iota(vals.begin(), vals.end(), 0.0);
3939

‎ElementsKernel/tests/src/Logging_test.cpp‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ using boost::filesystem::exists;
5353
class LogMessageTracker {
5454
public:
5555
explicit LogMessageTracker(std::ostream& stream)
56-
: m_messages{}, m_stream(stream), m_old{stream.rdbuf(m_messages.rdbuf())} {}
56+
: m_stream(stream), m_old{stream.rdbuf(m_messages.rdbuf())} {}
5757
~LogMessageTracker() {
5858
m_stream.rdbuf(m_old);
5959
}
@@ -142,7 +142,7 @@ BOOST_FIXTURE_TEST_CASE(loggerNames_test, ElementsLogging_Fixture) {
142142
BOOST_FIXTURE_TEST_CASE(messageTextAndLevel_test, ElementsLogging_Fixture) {
143143

144144
// Given
145-
Elements::Logging::setLevel("DEBUG");
145+
Logging::setLevel("DEBUG");
146146

147147
// When
148148
m_logger.debug("Debug message");
@@ -225,7 +225,7 @@ BOOST_FIXTURE_TEST_CASE(messageTextAndLevel_test, ElementsLogging_Fixture) {
225225
BOOST_FIXTURE_TEST_CASE(setLevel_test, ElementsLogging_Fixture) {
226226

227227
// Given
228-
Elements::Logging::setLevel("DEBUG");
228+
Logging::setLevel("DEBUG");
229229

230230
// When
231231
m_logger.debug("Debug message");
@@ -240,7 +240,7 @@ BOOST_FIXTURE_TEST_CASE(setLevel_test, ElementsLogging_Fixture) {
240240

241241
// Given
242242
m_tracker.reset();
243-
Elements::Logging::setLevel("INFO");
243+
Logging::setLevel("INFO");
244244

245245
// When
246246
m_logger.debug("Debug message");
@@ -255,7 +255,7 @@ BOOST_FIXTURE_TEST_CASE(setLevel_test, ElementsLogging_Fixture) {
255255

256256
// Given
257257
m_tracker.reset();
258-
Elements::Logging::setLevel("WARN");
258+
Logging::setLevel("WARN");
259259

260260
// When
261261
m_logger.debug("Debug message");
@@ -270,7 +270,7 @@ BOOST_FIXTURE_TEST_CASE(setLevel_test, ElementsLogging_Fixture) {
270270

271271
// Given
272272
m_tracker.reset();
273-
Elements::Logging::setLevel("ERROR");
273+
Logging::setLevel("ERROR");
274274

275275
// When
276276
m_logger.debug("Debug message");
@@ -285,7 +285,7 @@ BOOST_FIXTURE_TEST_CASE(setLevel_test, ElementsLogging_Fixture) {
285285

286286
// Given
287287
m_tracker.reset();
288-
Elements::Logging::setLevel("FATAL");
288+
Logging::setLevel("FATAL");
289289

290290
// When
291291
m_logger.debug("Debug message");

‎ElementsKernel/tests/src/ModuleInfo_test.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ BOOST_AUTO_TEST_CASE(moduleNameFull_test) {
9494

9595
string module = ::basename(const_cast<char*>(module_name_full.c_str()));
9696

97-
BOOST_CHECK_EQUAL(module.substr(static_cast<string::size_type>(0), module.find('.')), "libElementsKernel");
97+
BOOST_CHECK_EQUAL(module.substr(0, module.find('.')), "libElementsKernel");
9898
}
9999

100100
BOOST_AUTO_TEST_CASE(exeHandle_test) {

‎ElementsKernel/tests/src/Storage_test.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ using std::int64_t;
3131

3232
namespace Elements {
3333

34-
using Kernel::Units::storageConvert;
35-
using Kernel::Units::StorageType;
34+
using Units::storageConvert;
35+
using Units::StorageType;
3636

3737
//-----------------------------------------------------------------------------
3838
//

‎ElementsKernel/tests/src/SystemOfUnits_test.cpp‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,31 +32,31 @@ BOOST_AUTO_TEST_SUITE(SystemOfUnits_test)
3232

3333
BOOST_AUTO_TEST_CASE(LuminousFlux_test) {
3434

35-
using Kernel::Units::jansky;
36-
using Kernel::Units::microjansky;
37-
using Kernel::Units::perMillion;
35+
using Units::jansky;
36+
using Units::microjansky;
37+
using Units::perMillion;
3838

3939
BOOST_CHECK(isEqual(microjansky, jansky * perMillion));
4040
}
4141

4242
BOOST_AUTO_TEST_CASE(Illuminance_test) {
4343

44-
using Kernel::Units::lumen;
45-
using Kernel::Units::lux;
46-
using Kernel::Units::meter2;
44+
using Units::lumen;
45+
using Units::lux;
46+
using Units::meter2;
4747

4848
BOOST_CHECK(isEqual(lux, lumen / meter2));
4949
}
5050

5151
BOOST_AUTO_TEST_CASE(Misc_test) {
5252

53-
using Kernel::Units::perCent;
53+
using Units::perCent;
5454
BOOST_CHECK(isEqual(perCent, 1.0 / 100.0));
5555

56-
using Kernel::Units::perThousand;
56+
using Units::perThousand;
5757
BOOST_CHECK(isEqual(perThousand, 1.0 / 1000.0));
5858

59-
using Kernel::Units::perMillion;
59+
using Units::perMillion;
6060
BOOST_CHECK(isEqual(perMillion, 1.0 / 1.0e6));
6161
}
6262

‎ElementsServices/src/lib/DataSync/DependencyConfiguration.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ using std::string;
3737
using std::vector;
3838

3939
DependencyConfiguration::DependencyConfiguration(path distantRoot, path localRoot, const path& configFile)
40-
: m_aliasSeparator('\t'), m_distantRoot(std::move(distantRoot)), m_localRoot(std::move(localRoot)), m_fileMap() {
40+
: m_aliasSeparator('\t'), m_distantRoot(std::move(distantRoot)), m_localRoot(std::move(localRoot)) {
4141
parseConfigurationFile(configFile);
4242
}
4343

0 commit comments

Comments
 (0)