]> git.eshelyaron.com Git - emacs.git/commitdiff
* callproc.c (egetenv_internal): Add arg and rename from egetenv ...
authorDmitry Antipov <dmantipov@yandex.ru>
Tue, 2 Sep 2014 06:49:40 +0000 (10:49 +0400)
committerDmitry Antipov <dmantipov@yandex.ru>
Tue, 2 Sep 2014 06:49:40 +0000 (10:49 +0400)
* lisp.h (egetenv): ... because of a new inline function used to
avoid calls to strlen for a compile-time constants.

src/ChangeLog
src/callproc.c
src/lisp.h

index 2de909ef800701c73279fe2a0a5c695ef00958c1..3ce27b1ce19cd87903935d78c23e10fb976b6bac 100644 (file)
@@ -3,6 +3,9 @@
        * fileio.c (CHECK_LENGTH): New macro.
        (Fexpand_file_name): Use it and get rid of a few more calls
        to strlen and strcat.
+       * 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.
 
 2014-09-01  Dmitry Antipov  <dmantipov@yandex.ru>
 
index 0100831215528f26def45d25b07111545252539d..e8b61b9f01f84c683a9f3d68da56d49f52ce07eb 100644 (file)
@@ -1488,14 +1488,14 @@ If optional parameter ENV is a list, then search this list instead of
 }
 
 /* A version of getenv that consults the Lisp environment lists,
-   easily callable from C.  */
+   easily callable from C.  This is usually called from egetenv.  */
 char *
-egetenv (const char *var)
+egetenv_internal (const char *var, ptrdiff_t len)
 {
   char *value;
   ptrdiff_t valuelen;
 
-  if (getenv_internal (var, strlen (var), &value, &valuelen, Qnil))
+  if (getenv_internal (var, len, &value, &valuelen, Qnil))
     return value;
   else
     return 0;
index 05b27ab9f00379632a45def37dabde3cf10a7c27..cac536943a55ecf625b46200afcf3a22c38d5329 100644 (file)
@@ -4442,7 +4442,16 @@ extern char *xlispstrdup (Lisp_Object) ATTRIBUTE_MALLOC;
 extern void dupstring (char **, char const *);
 extern void xputenv (const char *);
 
-extern char *egetenv (const char *);
+extern char *egetenv_internal (const char *, ptrdiff_t);
+
+/* VAR is usually a compile-time constant, so the
+   call to strlen is likely to be optimized away.  */
+
+INLINE char *
+egetenv(const char *var)
+{
+  return egetenv_internal (var, strlen (var));
+}
 
 /* Copy Lisp string to temporary (allocated on stack) C string.  */