Skip to content

Commit 13759e1

Browse files
authored
Merge pull request #243 adding a pure attribute to getIndex() from KOLANICH/efficiency_2
Efficiency - adding a pure attribute to getIndex()
2 parents 91fe2d7 + 51bd6d6 commit 13759e1

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

include/SQLiteCpp/Statement.h

+27
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,32 @@
1616
#include <map>
1717
#include <climits> // For INT_MAX
1818

19+
// some macros are taken from https://github.com/nemequ/hedley/blob/master/hedley.h , it was public domain that time
20+
#if defined(__GNUC__) || defined(__GNUG__) || defined(__clang__) ||\
21+
(defined(__INTEL_COMPILER) && __INTEL_COMPILER > 1600) ||\
22+
(defined(__ARMCC_VERSION) && __ARMCC_VERSION > 4010000) ||\
23+
(\
24+
defined(__TI_COMPILER_VERSION__) && (\
25+
__TI_COMPILER_VERSION__ > 8003000 ||\
26+
(__TI_COMPILER_VERSION__ > 7003000 && defined(__TI_GNU_ATTRIBUTE_SUPPORT__))\
27+
)\
28+
)
29+
#if defined(__has_attribute)
30+
#if !defined(SQLITECPP_PURE_FUNC) && __has_attribute(const)
31+
#define SQLITECPP_PURE_FUNC __attribute__((const))
32+
#endif
33+
#endif
34+
#endif
35+
#if !defined(SQLITECPP_PURE_FUNC)
36+
#define SQLITECPP_PURE_FUNC
37+
#if defined(__GNUC__) || defined(__GNUG__) || defined(__clang__)
38+
#warning "You have a compiler without the needed macros or attributes. Cannot detect and apply support of pure const functions. Efficiency likely will be harmed. Consider using another compiler or its version"
39+
#elif _MSC_VER
40+
#pragma message "You have a compiler without the needed macros or attributes. Cannot detect and apply support of pure const functions. Efficiency likely will be harmed. Consider using another compiler or its version"
41+
#endif
42+
#endif
43+
44+
1945
// Forward declarations to avoid inclusion of <sqlite3.h> in a header
2046
struct sqlite3;
2147
struct sqlite3_stmt;
@@ -121,6 +147,7 @@ class Statement
121147
// instead of being copied.
122148
// => if you know what you are doing, use bindNoCopy() instead of bind()
123149

150+
SQLITECPP_PURE_FUNC
124151
int getIndex(const char * const apName);
125152

126153
/**

0 commit comments

Comments
 (0)