summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--array.c13
-rw-r--r--version.h2
3 files changed, 10 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index c5b7c5b..3bb0aa4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,13 @@
+Fri May 18 23:07:33 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * array.c (rb_ary_first): call rb_ary_subseq() instead of pushing
+ values by itself. [ruby-talk:252062]
+
Fri May 18 17:10:31 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* win32/win32.c (move_to_next_entry): loc also must move forward.
[ruby-talk:251987]
-
Fri May 18 03:02:40 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* win32/mkexports.rb: preserve prefixed underscores for WINAPI
diff --git a/array.c b/array.c
index acc59d2..e2bbf2b 100644
--- a/array.c
+++ b/array.c
@@ -748,17 +748,10 @@ rb_ary_first(argc, argv, ary)
return RARRAY(ary)->ptr[0];
}
else {
- VALUE nv, result;
- long n, i;
+ VALUE n;
- rb_scan_args(argc, argv, "01", &nv);
- n = NUM2LONG(nv);
- if (n > RARRAY(ary)->len) n = RARRAY(ary)->len;
- result = rb_ary_new2(n);
- for (i=0; i<n; i++) {
- rb_ary_push(result, RARRAY(ary)->ptr[i]);
- }
- return result;
+ rb_scan_args(argc, argv, "01", &n);
+ return rb_ary_subseq(ary, 0, NUM2LONG(n));
}
}
diff --git a/version.h b/version.h
index 1187802..50582a7 100644
--- a/version.h
+++ b/version.h
@@ -11,7 +11,9 @@
#define RUBY_RELEASE_MONTH 5
#define RUBY_RELEASE_DAY 18
+#ifdef RUBY_EXTERN
RUBY_EXTERN const char ruby_version[];
RUBY_EXTERN const char ruby_release_date[];
RUBY_EXTERN const char ruby_platform[];
RUBY_EXTERN const int ruby_patchlevel;
+#endif