From d9231f3bc5afc9b78d437a48ccd609bab56fdd1f Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Tue, 9 Dec 2008 17:53:00 -0600 Subject: [PATCH] Remove unsafe string allocation, since its of dubious value --- basis/tools/walker/walker.factor | 4 ---- core/bootstrap/primitives.factor | 1 - core/sbufs/sbufs.factor | 2 +- core/sequences/sequences.factor | 5 +---- core/strings/strings.factor | 2 -- 5 files changed, 2 insertions(+), 12 deletions(-) diff --git a/basis/tools/walker/walker.factor b/basis/tools/walker/walker.factor index a614e2eb0a..8915d2d611 100644 --- a/basis/tools/walker/walker.factor +++ b/basis/tools/walker/walker.factor @@ -152,10 +152,6 @@ SYMBOL: +stopped+ >n ndrop >c c> continue continue-with stop suspend (spawn) - ! Don't step into some sequence words since output of - ! (string) and new-sequence-unsafe may not print due to - ! memory safety issues - prepare-subseq subseq new-sequence-unsafe } [ dup [ execute break ] curry "step-into" set-word-prop diff --git a/core/bootstrap/primitives.factor b/core/bootstrap/primitives.factor index 79cc922f78..6cc97531a4 100644 --- a/core/bootstrap/primitives.factor +++ b/core/bootstrap/primitives.factor @@ -520,7 +520,6 @@ tuple { "" "kernel" } { "(clone)" "kernel" } { "" "strings" } - { "(string)" "strings.private" } { "array>quotation" "quotations.private" } { "quotation-xt" "quotations" } { "" "classes.tuple.private" } diff --git a/core/sbufs/sbufs.factor b/core/sbufs/sbufs.factor index 0b6f089443..5590432ef4 100644 --- a/core/sbufs/sbufs.factor +++ b/core/sbufs/sbufs.factor @@ -8,7 +8,7 @@ TUPLE: sbuf { underlying string } { length array-capacity } ; -: ( n -- sbuf ) (string) 0 sbuf boa ; inline +: ( n -- sbuf ) 0 0 sbuf boa ; inline M: sbuf set-nth-unsafe [ >fixnum ] [ >fixnum ] [ underlying>> ] tri* set-string-nth ; diff --git a/core/sequences/sequences.factor b/core/sequences/sequences.factor index 8083cffe97..8c9eff94f5 100644 --- a/core/sequences/sequences.factor +++ b/core/sequences/sequences.factor @@ -81,7 +81,6 @@ GENERIC: resize ( n seq -- newseq ) flushable ! Unsafe sequence protocol for inner loops GENERIC: nth-unsafe ( n seq -- elt ) flushable GENERIC: set-nth-unsafe ( elt n seq -- ) -GENERIC: new-sequence-unsafe ( len seq -- newseq ) flushable M: sequence nth bounds-check nth-unsafe ; M: sequence set-nth bounds-check set-nth-unsafe ; @@ -89,8 +88,6 @@ M: sequence set-nth bounds-check set-nth-unsafe ; M: sequence nth-unsafe nth ; M: sequence set-nth-unsafe set-nth ; -M: sequence new-sequence-unsafe new-sequence ; - ! The f object supports the sequence protocol trivially M: f length drop 0 ; M: f nth-unsafe nip ; @@ -259,7 +256,7 @@ INSTANCE: repetition immutable-sequence : prepare-subseq ( from to seq -- dst i src j n ) #! The check-length call forces partial dispatch - [ [ swap - ] dip new-sequence-unsafe dup 0 ] 3keep + [ [ swap - ] dip new-sequence dup 0 ] 3keep -rot drop roll length check-length ; inline : check-copy ( src n dst -- ) diff --git a/core/strings/strings.factor b/core/strings/strings.factor index 6da7bfce0d..0c3f918fdc 100644 --- a/core/strings/strings.factor +++ b/core/strings/strings.factor @@ -56,6 +56,4 @@ M: string resize resize-string ; M: string new-sequence drop 0 ; -M: string new-sequence-unsafe drop (string) ; - INSTANCE: string sequence