summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-07-26 18:55:44 +0300
committerAndrei Karas <akaras@inbox.ru>2015-07-26 18:55:44 +0300
commit8c3d197dbdfc00969f30309ee7bf52656b33ed1b (patch)
tree1ae60266bcd76a6399921ad9a0d5a9f6af9ae1de /src/utils
parentb29f6896196376a6b3c2abf60de766811264af75 (diff)
downloadmv-8c3d197dbdfc00969f30309ee7bf52656b33ed1b.tar.gz
mv-8c3d197dbdfc00969f30309ee7bf52656b33ed1b.tar.bz2
mv-8c3d197dbdfc00969f30309ee7bf52656b33ed1b.tar.xz
mv-8c3d197dbdfc00969f30309ee7bf52656b33ed1b.zip
Fix code style.
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/mathutils.h152
-rw-r--r--src/utils/xml.cpp6
2 files changed, 104 insertions, 54 deletions
diff --git a/src/utils/mathutils.h b/src/utils/mathutils.h
index 37de98b54..36889306d 100644
--- a/src/utils/mathutils.h
+++ b/src/utils/mathutils.h
@@ -66,56 +66,106 @@ static constexpr const uint16_t crc_table[256] =
static constexpr const uint8_t square_roots[1000] =
{
- 0, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,
- 10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,
- 11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
- 12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,13,13,
- 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,14,14,14,14,
- 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,
- 14,14,14,14,14,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
- 15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,16,16,16,16,
- 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
- 16,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,17,17,17,
- 17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
- 17,17,17,17,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,
- 18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,
- 18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,
- 19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,
- 20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,
- 20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,
- 20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,
- 21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,
- 21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,
- 22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,
- 22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,
- 23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,
- 23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,
- 24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,
- 24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,
- 24,24,24,24,24,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,27,27,27,27,27,27,27,27,27,27,27,
- 27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,
- 27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,
- 27,27,27,27,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,
- 28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,
- 28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,
- 28,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,
- 29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,
- 29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,
- 30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,
- 30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,
- 30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,
- 30,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,
- 31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31
+ 0, 1, 1, 1, 2, 2, 2, 2, 2, 3,
+ 3, 3, 3, 3, 3, 3, 4, 4, 4, 4,
+ 4, 4, 4, 4, 4, 5, 5, 5, 5, 5,
+ 5, 5, 5, 5, 5, 5, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 7,
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+ 7, 7, 7, 7, 8, 8, 8, 8, 8, 8,
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+ 8, 9, 9, 9, 9, 9, 9, 9, 9, 9,
+ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
+ 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
+ 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
+ 10, 11, 11, 11, 11, 11, 11, 11, 11, 11,
+ 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
+ 11, 11, 11, 11, 12, 12, 12, 12, 12, 12,
+ 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
+ 12, 12, 12, 12, 12, 12, 12, 12, 12, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 14, 14, 14, 14,
+ 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
+ 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
+ 14, 14, 14, 14, 14, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 16, 16, 16, 16,
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 17,
+ 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
+ 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
+ 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
+ 17, 17, 17, 17, 18, 18, 18, 18, 18, 18,
+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+ 18, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+ 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+ 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+ 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
+ 20, 21, 21, 21, 21, 21, 21, 21, 21, 21,
+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
+ 21, 21, 21, 21, 22, 22, 22, 22, 22, 22,
+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 23,
+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
+ 23, 23, 23, 23, 23, 23, 24, 24, 24, 24,
+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
+ 24, 24, 24, 24, 24, 25, 25, 25, 25, 25,
+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
+ 25, 25, 25, 25, 25, 25, 26, 26, 26, 26,
+ 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
+ 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
+ 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
+ 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
+ 26, 26, 26, 26, 26, 26, 26, 26, 26, 27,
+ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
+ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
+ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
+ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
+ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
+ 27, 27, 27, 27, 28, 28, 28, 28, 28, 28,
+ 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
+ 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
+ 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
+ 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
+ 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
+ 28, 29, 29, 29, 29, 29, 29, 29, 29, 29,
+ 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
+ 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
+ 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
+ 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
+ 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
+ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
+ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
+ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
+ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
+ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
+ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
+ 30, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+ 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+ 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+ 31, 31, 31, 31, 31, 31, 31, 31, 31, 31
};
inline uint16_t getCrc16(const std::string &str) A_WARN_UNUSED;
@@ -190,7 +240,7 @@ constexpr2 inline int fastSqrtInt(const unsigned int n)
{
if (n < 1000)
return static_cast<int>(square_roots[n]);
- return sqrt(n);
+ return static_cast<int>(sqrt(n));
}
#endif // UTILS_MATHUTILS_H
diff --git a/src/utils/xml.cpp b/src/utils/xml.cpp
index e9b2260bf..16888fae4 100644
--- a/src/utils/xml.cpp
+++ b/src/utils/xml.cpp
@@ -49,14 +49,14 @@ static void xmlErrorLogger(void *ctx A_UNUSED, const char *msg A_UNUSED, ...)
static void xmlErrorLogger(void *ctx A_UNUSED, const char *msg, ...)
{
+ if (!msg)
+ return;
+
size_t size = 1024;
const size_t msgSize = strlen(msg);
if (msgSize * 3 > size)
size = msgSize * 3;
- if (!msg)
- return;
-
char* buf = new char[size + 1];
va_list ap;