From cb3128d24101a7da7b563e27d62829e75a8d529c Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Sun, 2 Feb 2014 12:27:24 +0900 Subject: [PATCH] refactor values functions --- src/cont.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/cont.c b/src/cont.c index ae6b3c36..3164ee6d 100644 --- a/src/cont.c +++ b/src/cont.c @@ -179,38 +179,30 @@ pic_values(pic_state *pic, size_t c, ...) { va_list ap; size_t i; - pic_value head = pic_none_value(); va_start(ap, c); for (i = 0; i < c; ++i) { pic->ci->fp[i] = va_arg(ap, pic_value); - if (i == 0) { - head = pic->ci->fp[0]; - } } pic->ci->fp[i] = pic_undef_value(); va_end(ap); - return head; + return c == 0 ? pic_none_value() : pic->ci->fp[0]; } pic_value pic_values_by_array(pic_state *pic, size_t argc, pic_value *argv) { size_t i; - pic_value head = pic_none_value(); for (i = 0; i < argc; ++i) { pic->ci->fp[i] = argv[i]; - if (i == 0) { - head = pic->ci->fp[0]; - } } pic->ci->fp[i] = pic_undef_value(); - return head; + return argc == 0 ? pic_none_value() : pic->ci->fp[0]; } static pic_value