aboutsummaryrefslogtreecommitdiffstats
path: root/hash.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-08-05 08:04:04 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-08-05 08:04:04 +0000
commit5f8e2d383b1252be4acbac6d50177acd8e79dff9 (patch)
tree42620002620fd7b7a8d89256f3aa94cd458bcbdf /hash.c
parent8e627f61bc1b0eccb3fa75d92831ac1f47c74d1f (diff)
downloadruby-5f8e2d383b1252be4acbac6d50177acd8e79dff9.tar.gz
hash.c: call w32_getenv pointer
* hash.c (w32_getenv): call rb_w32_getenv and rb_w32_ugetenv via this pointer without further comparisons. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55813 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/hash.c b/hash.c
index d6bfc8a613..3af376255e 100644
--- a/hash.c
+++ b/hash.c
@@ -2896,17 +2896,21 @@ static char **my_environ;
#undef environ
#define environ my_environ
#undef getenv
-static inline char *
-w32_getenv(const char *name)
+static char *(*w32_getenv)(const char*);
+static char *
+w32_getenv_unknown(const char *name)
{
- static int binary = -1;
- static int locale = -1;
- if (binary < 0) {
- binary = rb_ascii8bit_encindex();
- locale = rb_locale_encindex();
+ char *(*func)(const char*);
+ if (rb_locale_encindex() == rb_ascii8bit_encindex()) {
+ func = rb_w32_getenv;
}
- return locale == binary ? rb_w32_getenv(name) : rb_w32_ugetenv(name);
+ else {
+ func = rb_w32_ugetenv;
+ }
+ /* atomic assignment in flat memory model */
+ return (w32_getenv = func)(name);
}
+static char *(*w32_getenv)(const char*) = w32_getenv_unknown;
#define getenv(n) w32_getenv(n)
#elif defined(__APPLE__)
#undef environ