From d3fc7ef6c2e7e75f2f00d59a20621d714050955d Mon Sep 17 00:00:00 2001
From: John Benediktsson <mrjbq7@gmail.com>
Date: Thu, 30 Aug 2012 11:32:12 -0700
Subject: [PATCH] unicode.case: slightly cleaner locale case handling.

---
 basis/unicode/case/case.factor | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/basis/unicode/case/case.factor b/basis/unicode/case/case.factor
index d14c765f4c..e19fd2ba84 100644
--- a/basis/unicode/case/case.factor
+++ b/basis/unicode/case/case.factor
@@ -17,10 +17,10 @@ SYMBOL: locale ! Just casing locale, or overall?
 : replace ( old new str -- newstr )
     [ split-subseq ] dip join ; inline
 
-: i-dot? ( -- ? )
-    locale get { "tr" "az" } member? ;
+: i-dot? ( locale -- ? )
+    { "tr" "az" } member? ; inline
 
-: lithuanian? ( -- ? ) locale get "lt" = ;
+: lithuanian? ( locale -- ? ) "lt" = ; inline
 
 : lithuanian>upper ( string -- lower )
     "i\u000307" "i" replace
@@ -80,19 +80,26 @@ SYMBOL: locale ! Just casing locale, or overall?
         [ char-quot call out push ] ?if
     ] each out "" like ; inline
 
+: locale>lower ( string -- string' )
+    locale get
+    [ i-dot? [ turk>lower ] when ]
+    [ lithuanian? [ lithuanian>lower ] when ] bi ;
+
+: locale>upper ( string -- string' )
+    locale get
+    [ i-dot? [ turk>upper ] when ]
+    [ lithuanian? [ lithuanian>upper ] when ] bi ;
+
 PRIVATE>
 
 : >lower ( string -- lower )
-    i-dot? [ turk>lower ] when
-    lithuanian? [ lithuanian>lower ] when
-    final-sigma
+    locale>lower final-sigma
     [ lower>> ] [ ch>lower ] map-case ;
 
 HINTS: >lower string ;
 
 : >upper ( string -- upper )
-    i-dot? [ turk>upper ] when
-    lithuanian? [ lithuanian>upper ] when
+    locale>upper
     [ upper>> ] [ ch>upper ] map-case ;
 
 HINTS: >upper string ;
@@ -100,8 +107,7 @@ HINTS: >upper string ;
 <PRIVATE
 
 : (>title) ( string -- title )
-    i-dot? [ turk>upper ] when
-    lithuanian? [ lithuanian>upper ] when
+    locale>upper
     [ title>> ] [ ch>title ] map-case ; inline
 
 PRIVATE>