Skip to content

Commit 221a6f1

Browse files
committed
lint code
1 parent d1d02e7 commit 221a6f1

File tree

3 files changed

+42
-39
lines changed

3 files changed

+42
-39
lines changed

cpp/fury/python/pyunicode.cc

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@
2121

2222
namespace fury {
2323

24-
static PyObject* unicode_latin1[256] = {nullptr};
24+
static PyObject *unicode_latin1[256] = {nullptr};
2525

26-
static PyObject* get_latin1_char(unsigned char ch) {
27-
PyObject* unicode = unicode_latin1[ch];
26+
static PyObject *get_latin1_char(unsigned char ch) {
27+
PyObject *unicode = unicode_latin1[ch];
2828
if (!unicode) {
2929
unicode = PyUnicode_New(1, ch);
30-
if (!unicode) return NULL;
30+
if (!unicode)
31+
return NULL;
3132
PyUnicode_1BYTE_DATA(unicode)[0] = ch;
3233
// assert(_PyUnicode_CheckConsistency(unicode, 1));
3334
unicode_latin1[ch] = unicode;
@@ -36,21 +37,23 @@ static PyObject* get_latin1_char(unsigned char ch) {
3637
return unicode;
3738
}
3839

39-
PyObject* Fury_PyUnicode_FromUCS1(const char* u, Py_ssize_t size) {
40-
PyObject* res;
40+
PyObject *Fury_PyUnicode_FromUCS1(const char *u, Py_ssize_t size) {
41+
PyObject *res;
4142
unsigned char max_char;
4243
FURY_CHECK(size > 0);
43-
if (size == 1) return get_latin1_char(u[0]);
44-
max_char = isAscii(reinterpret_cast<const char*>(u), size) ? 127 : 255;
44+
if (size == 1)
45+
return get_latin1_char(u[0]);
46+
max_char = isAscii(reinterpret_cast<const char *>(u), size) ? 127 : 255;
4547
res = PyUnicode_New(size, max_char);
46-
if (!res) return NULL;
48+
if (!res)
49+
return NULL;
4750
memcpy(PyUnicode_1BYTE_DATA(res), u, size);
4851
// assert(_PyUnicode_CheckConsistency(res, 1));
4952
return res;
5053
}
5154

52-
PyObject* Fury_PyUnicode_FromUCS2(const uint16_t* u, Py_ssize_t size) {
53-
PyObject* res;
55+
PyObject *Fury_PyUnicode_FromUCS2(const uint16_t *u, Py_ssize_t size) {
56+
PyObject *res;
5457
Py_UCS2 max_char;
5558
FURY_CHECK(size > 0);
5659
if (size == 1) {
@@ -79,9 +82,9 @@ PyObject* Fury_PyUnicode_FromUCS2(const uint16_t* u, Py_ssize_t size) {
7982
if (max_char >= 256) {
8083
memcpy(PyUnicode_2BYTE_DATA(res), u, sizeof(Py_UCS2) * size);
8184
} else {
82-
copyArray(u, PyUnicode_1BYTE_DATA(res), size);
85+
copyArray(u, PyUnicode_1BYTE_DATA(res), size);
8386
}
8487
// assert(_PyUnicode_CheckConsistency(res, 1));
8588
return res;
8689
}
87-
} // namespace fury
90+
} // namespace fury

cpp/fury/python/pyunicode.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@
1717
* under the License.
1818
*/
1919

20-
#include <string>
21-
#include <cstring>
2220
#include "fury/util/array_util.h"
2321
#include "fury/util/buffer.h"
2422
#include "fury/util/logging.h"
2523
#include "fury/util/string_util.h"
26-
#include "pyport.h"
2724
#include "object.h"
25+
#include "pyport.h"
2826
#include "unicodeobject.h"
27+
#include <cstring>
28+
#include <string>
2929

3030
namespace fury {
3131

3232
// unicodeobject.c
33-
PyObject* Fury_PyUnicode_FromUCS1(const char* u, Py_ssize_t size);
33+
PyObject *Fury_PyUnicode_FromUCS1(const char *u, Py_ssize_t size);
3434

35-
PyObject* Fury_PyUnicode_FromUCS2(const uint16_t* u, Py_ssize_t size);
35+
PyObject *Fury_PyUnicode_FromUCS2(const uint16_t *u, Py_ssize_t size);
3636

37-
} // namespace fury
37+
} // namespace fury

cpp/fury/util/array_util.h

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,21 @@
1818
*/
1919

2020
#pragma once
21-
#include <cstdint>
2221
#include "fury/util/platform.h"
22+
#include <cstdint>
2323

2424
namespace fury {
2525
#if defined(FURY_HAS_NEON)
26-
inline uint16_t getMaxValue(const uint16_t* arr, size_t length) {
26+
inline uint16_t getMaxValue(const uint16_t *arr, size_t length) {
2727
if (length == 0) {
28-
return 0; // Return 0 for empty arrays
28+
return 0; // Return 0 for empty arrays
2929
}
30-
uint16x8_t max_val = vdupq_n_u16(0); // Initialize max vector to zero
30+
uint16x8_t max_val = vdupq_n_u16(0); // Initialize max vector to zero
3131

3232
size_t i = 0;
3333
for (; i + 8 <= length; i += 8) {
3434
uint16x8_t current_val = vld1q_u16(&arr[i]);
35-
max_val = vmaxq_u16(max_val, current_val); // Max operation
35+
max_val = vmaxq_u16(max_val, current_val); // Max operation
3636
}
3737

3838
// Find the max value in the resulting vector
@@ -54,7 +54,7 @@ inline uint16_t getMaxValue(const uint16_t* arr, size_t length) {
5454
return max_neon;
5555
}
5656

57-
inline void copyArray(const uint16_t* from, uint8_t* to, size_t length) {
57+
inline void copyArray(const uint16_t *from, uint8_t *to, size_t length) {
5858
size_t i = 0;
5959
for (; i + 7 < length; i += 8) {
6060
uint16x8_t src = vld1q_u16(&from[i]);
@@ -68,22 +68,22 @@ inline void copyArray(const uint16_t* from, uint8_t* to, size_t length) {
6868
}
6969
}
7070
#elif defined(FURY_HAS_SSE2)
71-
inline uint16_t getMaxValue(const uint16_t* arr, size_t length) {
71+
inline uint16_t getMaxValue(const uint16_t *arr, size_t length) {
7272
if (length == 0) {
73-
return 0; // Return 0 for empty arrays
73+
return 0; // Return 0 for empty arrays
7474
}
7575

76-
__m128i max_val = _mm_setzero_si128(); // Initialize max vector with zeros
76+
__m128i max_val = _mm_setzero_si128(); // Initialize max vector with zeros
7777

7878
size_t i = 0;
7979
for (; i + 8 <= length; i += 8) {
80-
__m128i current_val = _mm_loadu_si128((__m128i*)&arr[i]);
81-
max_val = _mm_max_epu16(max_val, current_val); // Max operation
80+
__m128i current_val = _mm_loadu_si128((__m128i *)&arr[i]);
81+
max_val = _mm_max_epu16(max_val, current_val); // Max operation
8282
}
8383

8484
// Find the max value in the resulting vector
8585
uint16_t temp[8];
86-
_mm_storeu_si128((__m128i*)temp, max_val);
86+
_mm_storeu_si128((__m128i *)temp, max_val);
8787
uint16_t max_sse = temp[0];
8888
for (int j = 1; j < 8; j++) {
8989
if (temp[j] > max_sse) {
@@ -100,13 +100,13 @@ inline uint16_t getMaxValue(const uint16_t* arr, size_t length) {
100100
return max_sse;
101101
}
102102

103-
inline void copyArray(const uint16_t* from, uint8_t* to, size_t length) {
103+
inline void copyArray(const uint16_t *from, uint8_t *to, size_t length) {
104104
size_t i = 0;
105-
__m128i mask = _mm_set1_epi16(0xFF); // Mask to zero out the high byte
105+
__m128i mask = _mm_set1_epi16(0xFF); // Mask to zero out the high byte
106106
for (; i + 7 < length; i += 8) {
107-
__m128i src = _mm_loadu_si128(reinterpret_cast<const __m128i*>(&from[i]));
107+
__m128i src = _mm_loadu_si128(reinterpret_cast<const __m128i *>(&from[i]));
108108
__m128i result = _mm_and_si128(src, mask);
109-
_mm_storel_epi64(reinterpret_cast<__m128i*>(&to[i]),
109+
_mm_storel_epi64(reinterpret_cast<__m128i *>(&to[i]),
110110
_mm_packus_epi16(result, result));
111111
}
112112

@@ -116,9 +116,9 @@ inline void copyArray(const uint16_t* from, uint8_t* to, size_t length) {
116116
}
117117
}
118118
#else
119-
inline uint16_t getMaxValue(const uint16_t* arr, size_t length) {
119+
inline uint16_t getMaxValue(const uint16_t *arr, size_t length) {
120120
if (length == 0) {
121-
return 0; // Return 0 for empty arrays
121+
return 0; // Return 0 for empty arrays
122122
}
123123
uint16_t max_val = arr[0];
124124
for (size_t i = 1; i < length; i++) {
@@ -129,11 +129,11 @@ inline uint16_t getMaxValue(const uint16_t* arr, size_t length) {
129129
return max_val;
130130
}
131131

132-
inline void copyArray(const uint16_t* from, uint8_t* to, size_t length) {
132+
inline void copyArray(const uint16_t *from, uint8_t *to, size_t length) {
133133
// Fallback for systems without SSE2/NEON
134134
for (size_t i = 0; i < length; ++i) {
135135
to[i] = static_cast<uint8_t>(from[i]);
136136
}
137137
}
138138
#endif
139-
} // namespace fury
139+
} // namespace fury

0 commit comments

Comments
 (0)