From bd56ab985e5b643c498978e8ec8556f15573aad6 Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Wed, 20 Jul 2011 10:21:11 -0700 Subject: [PATCH] =?UTF-8?q?strings:=20the=20fast=20path=20for=20set-string?= =?UTF-8?q?-nth=20was=20being=20used=20inappropriately=20for=20negative=20?= =?UTF-8?q?numbers.=20use=20the=20fast=20path=20only=20for=20Z=20=E2=88=A9?= =?UTF-8?q?=20[0,=20127]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/strings/strings-tests.factor | 2 ++ core/strings/strings.factor | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/core/strings/strings-tests.factor b/core/strings/strings-tests.factor index 247bd8d007..bebdb32820 100644 --- a/core/strings/strings-tests.factor +++ b/core/strings/strings-tests.factor @@ -121,3 +121,5 @@ unit-test [ clone resize-string first ] keep = ] all-integers? ] unit-test + +[ HEX: 7fffff ] [ { -1 } >string first ] unit-test diff --git a/core/strings/strings.factor b/core/strings/strings.factor index f356d2a877..e57edf282a 100644 --- a/core/strings/strings.factor +++ b/core/strings/strings.factor @@ -19,7 +19,8 @@ IN: strings : (aux) ( n string -- byte-array m ) aux>> { byte-array } declare swap 1 fixnum-shift-fast ; inline -: small-char? ( ch -- ? ) HEX: 7f fixnum<= ; inline +: small-char? ( ch -- ? ) + dup 0 fixnum>= [ HEX: 7f fixnum<= ] [ drop f ] if ; inline : string-nth ( n string -- ch ) 2dup string-nth-fast dup small-char?