From: Ben Pfaff Date: Fri, 19 Nov 2010 06:17:31 +0000 (-0800) Subject: str: Inline some trivial functions. X-Git-Tag: v0.7.7~130 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4b8c6191f0204d6a0b62650490ef2794d62ec79c;p=pspp-builds.git str: Inline some trivial functions. --- diff --git a/src/libpspp/str.c b/src/libpspp/str.c index 09eb77cd..6c2e3991 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 64da8562..4a219d7a 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 */