From a5811b4ecd58d1311076287bb2a5b54ec376910e Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 29 Oct 2009 19:47:28 +0000 Subject: * include/ruby/ruby.h (RSTRING_END): trivial optimization. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@25565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- include/ruby/ruby.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'include/ruby/ruby.h') diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h index 19f146e4a..55836a8fd 100644 --- a/include/ruby/ruby.h +++ b/include/ruby/ruby.h @@ -619,7 +619,12 @@ struct RString { (!(RBASIC(str)->flags & RSTRING_NOEMBED) ? \ RSTRING(str)->as.ary : \ RSTRING(str)->as.heap.ptr) -#define RSTRING_END(str) (RSTRING_PTR(str)+RSTRING_LEN(str)) +#define RSTRING_END(str) \ + (!(RBASIC(str)->flags & RSTRING_NOEMBED) ? \ + (RSTRING(str)->as.ary + \ + ((RBASIC(str)->flags >> RSTRING_EMBED_LEN_SHIFT) & \ + (RSTRING_EMBED_LEN_MASK >> RSTRING_EMBED_LEN_SHIFT))) : \ + (RSTRING(str)->as.heap.ptr + RSTRING(str)->as.heap.len)) #define RARRAY_EMBED_LEN_MAX 3 struct RArray { -- cgit