[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/5] str: Inline some trivial functions.
From: |
Ben Pfaff |
Subject: |
[PATCH 1/5] str: Inline some trivial functions. |
Date: |
Thu, 18 Nov 2010 22:21:28 -0800 |
---
src/libpspp/str.c | 29 -----------------------------
src/libpspp/str.h | 35 +++++++++++++++++++++++++++++++----
2 files changed, 31 insertions(+), 33 deletions(-)
diff --git a/src/libpspp/str.c b/src/libpspp/str.c
index 09eb77c..6c2e399 100644
--- a/src/libpspp/str.c
+++ b/src/libpspp/str.c
@@ -293,35 +293,6 @@ mempset (void *block, int c, size_t size)
/* Substrings. */
-/* Returns an empty substring. */
-struct substring
-ss_empty (void)
-{
- struct substring ss;
- ss.string = NULL;
- ss.length = 0;
- return ss;
-}
-
-/* Returns a substring whose contents are the given C-style
- string CSTR. */
-struct substring
-ss_cstr (const char *cstr)
-{
- return ss_buffer (cstr, strlen (cstr));
-}
-
-/* Returns a substring whose contents are the CNT characters in
- BUFFER. */
-struct substring
-ss_buffer (const char *buffer, size_t cnt)
-{
- struct substring ss;
- ss.string = (char *) buffer;
- ss.length = cnt;
- return ss;
-}
-
/* Returns a substring whose contents are the CNT characters
starting at the (0-based) position START in SS. */
struct substring
diff --git a/src/libpspp/str.h b/src/libpspp/str.h
index 64da856..4a219d7 100644
--- a/src/libpspp/str.h
+++ b/src/libpspp/str.h
@@ -72,9 +72,9 @@ struct substring
/* Constructors.
These functions do not allocate any memory, so the substrings
they create should not normally be destroyed. */
-struct substring ss_empty (void);
-struct substring ss_cstr (const char *);
-struct substring ss_buffer (const char *, size_t);
+static inline struct substring ss_empty (void);
+static inline struct substring ss_cstr (const char *);
+static inline struct substring ss_buffer (const char *, size_t);
struct substring ss_substr (struct substring, size_t start, size_t);
struct substring ss_head (struct substring, size_t);
struct substring ss_tail (struct substring, size_t);
@@ -226,6 +226,33 @@ void ds_relocate (struct string *st);
void u8_buf_copy_rpad (uint8_t *dst, size_t dst_size,
const uint8_t *src, size_t src_size,
char pad);
-
+
+struct substring
+ss_empty (void)
+{
+ struct substring ss;
+ ss.string = NULL;
+ ss.length = 0;
+ return ss;
+}
+
+/* Returns a substring whose contents are the given C-style
+ string CSTR. */
+static inline struct substring
+ss_cstr (const char *cstr)
+{
+ return ss_buffer (cstr, strlen (cstr));
+}
+
+/* Returns a substring whose contents are the CNT characters in
+ BUFFER. */
+static inline struct substring
+ss_buffer (const char *buffer, size_t cnt)
+{
+ struct substring ss;
+ ss.string = (char *) buffer;
+ ss.length = cnt;
+ return ss;
+}
#endif /* str_h */
--
1.7.1
- [PATCH 0/5] refactor command name parsing, Ben Pfaff, 2010/11/19
- [PATCH 1/5] str: Inline some trivial functions.,
Ben Pfaff <=
- [PATCH 3/5] str: Add some functions for handling UTF-8., Ben Pfaff, 2010/11/19
- [PATCH 4/5] identifier: Add some functions for Unicode syntax., Ben Pfaff, 2010/11/19
- [PATCH 5/5] command: Factor command name matching out of command.c., Ben Pfaff, 2010/11/19
- [PATCH 2/5] str: Change "char" to "byte" in function names., Ben Pfaff, 2010/11/19
- Re: [PATCH 0/5] refactor command name parsing, John Darrington, 2010/11/19