ruby-changes:61986
From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Mon, 29 Jun 2020 11:06:32 +0900 (JST)
Subject: [ruby-changes:61986] 70857ae1aa (master): glob_make_pattern: do not goto into a branch
https://git.ruby-lang.org/ruby.git/commit/?id=70857ae1aa From 70857ae1aa06c85f4c2366aed9a716dfa778ca1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= <shyouhei@r...> Date: Fri, 12 Jun 2020 14:00:35 +0900 Subject: glob_make_pattern: do not goto into a branch I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor. diff --git a/dir.c b/dir.c index bb2c625..42e5304 100644 --- a/dir.c +++ b/dir.c @@ -1705,10 +1705,7 @@ glob_make_pattern(const char *p, const char *e, int flags, rb_encoding *enc) https://github.com/ruby/ruby/blob/trunk/dir.c#L1705 tmp = GLOB_ALLOC(struct glob_pattern); if (!tmp) { - error: - *tail = 0; - glob_free_pattern(list); - return 0; + goto error; } tmp->type = dirsep ? MATCH_DIR : MATCH_ALL; tmp->str = 0; @@ -1716,6 +1713,11 @@ glob_make_pattern(const char *p, const char *e, int flags, rb_encoding *enc) https://github.com/ruby/ruby/blob/trunk/dir.c#L1713 tmp->next = 0; return list; + + error: + *tail = 0; + glob_free_pattern(list); + return 0; } static void -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/