From c0c769a7d882f946def5b348eaf8b13347ba130c Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Sun, 10 Mar 2013 09:11:18 -0700 Subject: [PATCH] compiler.units: changing definitions-changed to use a set. --- basis/help/home/home.factor | 4 +-- basis/help/markup/markup.factor | 14 ++++++---- basis/tools/deprecation/deprecation.factor | 4 +-- basis/ui/tools/browser/browser.factor | 22 +++++++-------- core/compiler/units/units.factor | 32 ++++++++++++---------- core/source-files/source-files.factor | 2 +- core/vocabs/parser/parser.factor | 2 +- 7 files changed, 42 insertions(+), 38 deletions(-) diff --git a/basis/help/home/home.factor b/basis/help/home/home.factor index 0239ba05f7..f4b7e4603e 100644 --- a/basis/help/home/home.factor +++ b/basis/help/home/home.factor @@ -28,7 +28,7 @@ M: object add-recent-where f ; drop recent-searches get [ <$link> ] map $list ; : redisplay-recent-page ( -- ) - "help.home" >link dup associate + HS{ } clone "help.home" >link over adjoin notify-definition-observers ; : expire ( seq -- ) @@ -38,4 +38,4 @@ M: object add-recent-where f ; : add-recent ( obj -- ) add-recent-where dup [ get [ adjoin ] [ expire ] bi ] [ 2drop ] if - redisplay-recent-page ; \ No newline at end of file + redisplay-recent-page ; diff --git a/basis/help/markup/markup.factor b/basis/help/markup/markup.factor index 4ac9bfc387..f4a000ac64 100644 --- a/basis/help/markup/markup.factor +++ b/basis/help/markup/markup.factor @@ -2,11 +2,12 @@ ! See http://factorcode.org/license.txt for BSD license. USING: accessors arrays assocs classes colors colors.constants combinators combinators.smart compiler.units definitions -definitions.icons effects fry generic hashtables help.stylesheet -help.topics io io.styles kernel locals make math namespaces -parser present prettyprint prettyprint.stylesheet quotations -see sequences sequences.private sets slots sorting splitting -strings urls vectors vocabs vocabs.loader words words.symbol ; +definitions.icons effects fry generic hash-sets hashtables +help.stylesheet help.topics io io.styles kernel locals make math +namespaces parser present prettyprint prettyprint.stylesheet +quotations see sequences sequences.private sets slots sorting +splitting strings urls vectors vocabs vocabs.loader words +words.symbol ; FROM: prettyprint.sections => with-pprint ; FROM: namespaces => set ; IN: help.markup @@ -301,7 +302,8 @@ PRIVATE> [ "related" [ words diff ] change-word-prop ] each ; : notify-related-words ( affected-words -- ) - [ dup associate notify-definition-observers ] each ; + fast-set notify-definition-observers ; + PRIVATE> : related-words ( seq -- ) diff --git a/basis/tools/deprecation/deprecation.factor b/basis/tools/deprecation/deprecation.factor index 2434a2c1fd..9b760953ae 100644 --- a/basis/tools/deprecation/deprecation.factor +++ b/basis/tools/deprecation/deprecation.factor @@ -1,6 +1,6 @@ ! (c)2009 Joe Groff bsd license USING: accessors arrays assocs combinators.short-circuit -compiler.units debugger init io +compiler.units debugger init io sets io.streams.null kernel namespaces prettyprint sequences source-files.errors summary tools.crossref tools.crossref.private tools.errors words ; @@ -67,7 +67,7 @@ SINGLETON: deprecation-observer ] with-null-writer ; M: deprecation-observer definitions-changed - drop keys [ word? ] filter + drop members [ word? ] filter dup [ deprecated? ] any? not [ [ check-deprecations ] each ] [ drop initialize-deprecation-notes ] if ; diff --git a/basis/ui/tools/browser/browser.factor b/basis/ui/tools/browser/browser.factor index 15a3450438..c46bd44760 100644 --- a/basis/ui/tools/browser/browser.factor +++ b/basis/ui/tools/browser/browser.factor @@ -3,12 +3,12 @@ USING: accessors arrays assocs classes combinators combinators.short-circuit compiler.units debugger fry help help.apropos help.crossref help.home help.topics help.stylesheet -kernel models sequences ui ui.commands ui.gadgets ui.gadgets.borders -ui.gadgets.buttons ui.gadgets.editors ui.gadgets.glass -ui.gadgets.labels ui.gadgets.panes ui.gadgets.scrollers -ui.gadgets.status-bar ui.gadgets.tracks ui.gadgets.viewports -ui.gestures ui.tools.browser.history ui.tools.browser.popups -ui.tools.common vocabs ; +kernel models sequences sets ui ui.commands ui.gadgets +ui.gadgets.borders ui.gadgets.buttons ui.gadgets.editors +ui.gadgets.glass ui.gadgets.labels ui.gadgets.panes +ui.gadgets.scrollers ui.gadgets.status-bar ui.gadgets.tracks +ui.gadgets.viewports ui.gestures ui.tools.browser.history +ui.tools.browser.popups ui.tools.common vocabs ; IN: ui.tools.browser TUPLE: browser-gadget < tool history scroller search-field popup ; @@ -75,14 +75,14 @@ M: browser-gadget handle-gesture [ call-next-method ] } cond ; -: showing-definition? ( defspec assoc -- ? ) +: showing-definition? ( defspec set -- ? ) { - [ key? ] - [ [ dup word-link? [ name>> ] when ] dip key? ] - [ [ dup vocab-link? [ lookup-vocab ] when ] dip key? ] + [ in? ] + [ [ dup word-link? [ name>> ] when ] dip in? ] + [ [ dup vocab-link? [ lookup-vocab ] when ] dip in? ] } 2|| ; -M: browser-gadget definitions-changed ( assoc browser -- ) +M: browser-gadget definitions-changed ( set browser -- ) [ model>> value>> swap showing-definition? ] keep '[ _ [ history-value ] keep set-history-value ] when ; diff --git a/core/compiler/units/units.factor b/core/compiler/units/units.factor index 004c725470..c949d6f6e9 100644 --- a/core/compiler/units/units.factor +++ b/core/compiler/units/units.factor @@ -5,6 +5,7 @@ classes.tuple classes.tuple.private continuations definitions generic init kernel kernel.private math namespaces sequences sets source-files.errors vocabs words ; FROM: namespaces => set ; +FROM: sets => members ; IN: compiler.units SYMBOL: old-definitions @@ -84,7 +85,7 @@ M: f process-forgotten-words drop ; SYMBOL: definition-observers -GENERIC: definitions-changed ( assoc obj -- ) +GENERIC: definitions-changed ( set obj -- ) [ V{ } clone definition-observers set-global ] "compiler.units" add-startup-hook @@ -99,7 +100,7 @@ GENERIC: definitions-changed ( assoc obj -- ) : remove-definition-observer ( obj -- ) definition-observers get remove-eq! drop ; -: notify-definition-observers ( assoc -- ) +: notify-definition-observers ( set -- ) definition-observers get [ definitions-changed ] with each ; @@ -114,18 +115,18 @@ M: object always-bump-effect-counter? drop f ; > dup [ lookup-vocab ] when dup ] assoc-map ; +: changed-vocabs ( set -- vocabs ) + members [ word? ] filter + [ vocabulary>> dup [ lookup-vocab ] when ] map ; -: updated-definitions ( -- assoc ) - H{ } clone - forgotten-definitions get assoc-union! - new-definitions get first assoc-union! - new-definitions get second assoc-union! - changed-definitions get assoc-union! - maybe-changed get assoc-union! - dup changed-vocabs assoc-union! ; +: updated-definitions ( -- set ) + HS{ } clone + forgotten-definitions get keys over adjoin-all + new-definitions get first keys over adjoin-all + new-definitions get second keys over adjoin-all + changed-definitions get keys over adjoin-all + maybe-changed get keys over adjoin-all + dup changed-vocabs over adjoin-all ; : process-forgotten-definitions ( -- ) forgotten-definitions get keys @@ -146,7 +147,7 @@ M: object always-bump-effect-counter? drop f ; ] when ; : notify-observers ( -- ) - updated-definitions dup assoc-empty? + updated-definitions dup null? [ drop ] [ notify-definition-observers notify-error-observers ] if ; : update-existing? ( defs -- ? ) @@ -169,7 +170,8 @@ M: object always-bump-effect-counter? drop f ; TUPLE: nesting-observer new-words ; -M: nesting-observer definitions-changed new-words>> swap assoc-diff! drop ; +M: nesting-observer definitions-changed + [ members ] dip new-words>> [ delete-at ] curry each ; : add-nesting-observer ( -- ) new-words get nesting-observer boa diff --git a/core/source-files/source-files.factor b/core/source-files/source-files.factor index 13e93f0582..aa040bdfcd 100644 --- a/core/source-files/source-files.factor +++ b/core/source-files/source-files.factor @@ -17,7 +17,7 @@ main ; : record-top-level-form ( quot file -- ) top-level-form<< - [ ] [ H{ } notify-definition-observers ] if-bootstrapping ; + [ ] [ f notify-definition-observers ] if-bootstrapping ; : record-checksum ( lines source-file -- ) [ crc32 checksum-lines ] dip checksum<< ; diff --git a/core/vocabs/parser/parser.factor b/core/vocabs/parser/parser.factor index c1438b1864..cd33131834 100644 --- a/core/vocabs/parser/parser.factor +++ b/core/vocabs/parser/parser.factor @@ -227,7 +227,7 @@ M: vocab update dup name>> lookup-vocab eq? ; swap [ lookup-vocab ] V{ } map-as >>search-vocabs qualified-vocabs>> [ update ] filter! drop ; -M: manifest definitions-changed ( assoc manifest -- ) +M: manifest definitions-changed nip update-manifest ; PRIVATE> -- 2.34.1