Skip to content

Commit

Permalink
"H{ } substitute" is faster than "{ } substitute".
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjbq7 committed Jul 14, 2012
1 parent d5ef0e0 commit 4f260ab
Show file tree
Hide file tree
Showing 11 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion basis/colors/constants/constants.factor
Expand Up @@ -9,7 +9,7 @@ IN: colors.constants
: parse-color ( line -- name color )
first4
[ [ string>number 255 /f ] tri@ 1.0 <rgba> ] dip
[ blank? ] trim-head { { CHAR: \s CHAR: - } } substitute swap ;
[ blank? ] trim-head H{ { CHAR: \s CHAR: - } } substitute swap ;

: parse-colors ( lines -- assoc )
[ "!" head? not ] filter
Expand Down
3 changes: 2 additions & 1 deletion basis/tools/test/test.factor
Expand Up @@ -77,7 +77,8 @@ M: did-not-fail summary drop "Did not fail" ;
[ { } quot with-datastack drop did-not-fail t ] [ drop f f ] recover ;

: experiment-title ( word -- string )
"(" ?head drop ")" ?tail drop { { CHAR: - CHAR: \s } } substitute >title ;
"(" ?head drop ")" ?tail drop
H{ { CHAR: - CHAR: \s } } substitute >title ;

MACRO: <experiment> ( word -- )
[ stack-effect in>> length dup ]
Expand Down
2 changes: 1 addition & 1 deletion basis/ui/text/pango/pango.factor
Expand Up @@ -120,7 +120,7 @@ SYMBOL: dpi
: escape-nulls ( str -- str' )
#! Replace nulls with something else since Pango uses null-terminated
#! strings
{ { 0 CHAR: zero-width-no-break-space } } substitute ;
H{ { 0 CHAR: zero-width-no-break-space } } substitute ;

: unpack-selection ( layout string/selection -- layout )
dup selection? [
Expand Down
2 changes: 1 addition & 1 deletion basis/ui/tools/listener/completion/completion.factor
Expand Up @@ -17,7 +17,7 @@ SLOT: history

: history-list ( interactor -- alist )
history>> elements>>
[ dup string>> { { CHAR: \n CHAR: \s } } substitute ] { } map>assoc
[ dup string>> H{ { CHAR: \n CHAR: \s } } substitute ] { } map>assoc
<reversed> ;

: history-completions ( short interactor -- seq )
Expand Down
2 changes: 1 addition & 1 deletion basis/unicode/data/data.factor
Expand Up @@ -158,7 +158,7 @@ PRIVATE>

: process-names ( data -- names-hash )
1 swap (process-data) [
>lower { { CHAR: \s CHAR: - } } substitute swap
>lower H{ { CHAR: \s CHAR: - } } substitute swap
] H{ } assoc-map-as ;

: multihex ( hexstring -- string )
Expand Down
2 changes: 1 addition & 1 deletion core/vocabs/loader/loader.factor
Expand Up @@ -42,7 +42,7 @@ M: string vocab-path ( string -- path/f )
PRIVATE>

: vocab-dir ( vocab -- dir )
vocab-name { { CHAR: . CHAR: / } } substitute ;
vocab-name H{ { CHAR: . CHAR: / } } substitute ;

: append-vocab-dir ( vocab str/f -- path )
[ vocab-name "." split ] dip
Expand Down
2 changes: 1 addition & 1 deletion extra/mason/platform/platform.factor
Expand Up @@ -5,7 +5,7 @@ mason.config bootstrap.image assocs ;
IN: mason.platform

: (platform) ( os cpu -- string )
{ { CHAR: . CHAR: - } } substitute "-" glue ;
H{ { CHAR: . CHAR: - } } substitute "-" glue ;

: platform ( -- string )
target-os get name>> target-cpu get name>> (platform)
Expand Down
2 changes: 1 addition & 1 deletion extra/svg/svg.factor
Expand Up @@ -10,7 +10,7 @@ XML-NS: sodipodi-name http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd
XML-NS: inkscape-name http://www.inkscape.org/namespaces/inkscape

: svg-string>number ( string -- number )
{ { CHAR: E CHAR: e } } substitute "e" split1
H{ { CHAR: E CHAR: e } } substitute "e" split1
[ string>number ] [ [ string>number 10^ ] [ 1 ] if* ] bi* *
>float ;

Expand Down
2 changes: 1 addition & 1 deletion unmaintained/alien/cxx/cxx.factor
Expand Up @@ -24,7 +24,7 @@ PRIVATE>
add-mixin-instance define-class-tuple ;

:: define-c++-method ( class-name generic name types effect virtual -- )
[ name % "_" % class-name { { CHAR: : CHAR: _ } } substitute % ] "" make :> name'
[ name % "_" % class-name H{ { CHAR: : CHAR: _ } } substitute % ] "" make :> name'
effect [ in>> "self" suffix ] [ out>> ] bi <effect> :> effect'
types class-name "*" append suffix :> types'
effect in>> "," join :> args
Expand Down
2 changes: 1 addition & 1 deletion unmaintained/alien/inline/types/types.factor
Expand Up @@ -7,7 +7,7 @@ IN: alien.inline.types

: cify-type ( str -- str' )
dup word? [ name>> ] when
{ { CHAR: - CHAR: space } } substitute ;
H{ { CHAR: - CHAR: space } } substitute ;

: factorize-type ( str -- str' )
cify-type
Expand Down
2 changes: 1 addition & 1 deletion unmaintained/alien/marshall/structs/structs.factor
Expand Up @@ -41,7 +41,7 @@ PRIVATE>
name c-type fields>> [
class swap
{
[ name>> { { CHAR: space CHAR: - } } substitute ]
[ name>> H{ { CHAR: space CHAR: - } } substitute ]
[ type>> ] [ reader>> ] [ writer>> ]
} cleave define-struct-accessors
] each ;
Expand Down

0 comments on commit 4f260ab

Please sign in to comment.