aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDmitry Antipov2014-09-02 10:49:40 +0400
committerDmitry Antipov2014-09-02 10:49:40 +0400
commitf25cd98b276ba1a11d7be5506c8624c72060b25f (patch)
tree856deb2cf42a6201b2479c5db9a351eefedbbf91 /src
parenta4a30aa0ecf0a9f032f2744548abf96b6d3d117e (diff)
downloademacs-f25cd98b276ba1a11d7be5506c8624c72060b25f.tar.gz
emacs-f25cd98b276ba1a11d7be5506c8624c72060b25f.zip
* callproc.c (egetenv_internal): Add arg and rename from egetenv ...
* lisp.h (egetenv): ... because of a new inline function used to avoid calls to strlen for a compile-time constants.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog3
-rw-r--r--src/callproc.c6
-rw-r--r--src/lisp.h11
3 files changed, 16 insertions, 4 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 2de909ef800..3ce27b1ce19 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -3,6 +3,9 @@
3 * fileio.c (CHECK_LENGTH): New macro. 3 * fileio.c (CHECK_LENGTH): New macro.
4 (Fexpand_file_name): Use it and get rid of a few more calls 4 (Fexpand_file_name): Use it and get rid of a few more calls
5 to strlen and strcat. 5 to strlen and strcat.
6 * callproc.c (egetenv_internal): Add arg and rename from egetenv ...
7 * lisp.h (egetenv): ... because of a new inline function used to
8 avoid calls to strlen for a compile-time constants.
6 9
72014-09-01 Dmitry Antipov <dmantipov@yandex.ru> 102014-09-01 Dmitry Antipov <dmantipov@yandex.ru>
8 11
diff --git a/src/callproc.c b/src/callproc.c
index 01008312155..e8b61b9f01f 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -1488,14 +1488,14 @@ If optional parameter ENV is a list, then search this list instead of
1488} 1488}
1489 1489
1490/* A version of getenv that consults the Lisp environment lists, 1490/* A version of getenv that consults the Lisp environment lists,
1491 easily callable from C. */ 1491 easily callable from C. This is usually called from egetenv. */
1492char * 1492char *
1493egetenv (const char *var) 1493egetenv_internal (const char *var, ptrdiff_t len)
1494{ 1494{
1495 char *value; 1495 char *value;
1496 ptrdiff_t valuelen; 1496 ptrdiff_t valuelen;
1497 1497
1498 if (getenv_internal (var, strlen (var), &value, &valuelen, Qnil)) 1498 if (getenv_internal (var, len, &value, &valuelen, Qnil))
1499 return value; 1499 return value;
1500 else 1500 else
1501 return 0; 1501 return 0;
diff --git a/src/lisp.h b/src/lisp.h
index 05b27ab9f00..cac536943a5 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -4442,7 +4442,16 @@ extern char *xlispstrdup (Lisp_Object) ATTRIBUTE_MALLOC;
4442extern void dupstring (char **, char const *); 4442extern void dupstring (char **, char const *);
4443extern void xputenv (const char *); 4443extern void xputenv (const char *);
4444 4444
4445extern char *egetenv (const char *); 4445extern char *egetenv_internal (const char *, ptrdiff_t);
4446
4447/* VAR is usually a compile-time constant, so the
4448 call to strlen is likely to be optimized away. */
4449
4450INLINE char *
4451egetenv(const char *var)
4452{
4453 return egetenv_internal (var, strlen (var));
4454}
4446 4455
4447/* Copy Lisp string to temporary (allocated on stack) C string. */ 4456/* Copy Lisp string to temporary (allocated on stack) C string. */
4448 4457