summaryrefslogtreecommitdiff
path: root/src/GF/Speech
diff options
context:
space:
mode:
authorbringert <unknown>2005-10-26 17:47:16 +0000
committerbringert <unknown>2005-10-26 17:47:16 +0000
commitf3bd409b1bd44f86d994a77704be56e8fd603675 (patch)
tree6eda15d05660f7b4069d4670a2eb938fd16c6c6f /src/GF/Speech
parenta01248d1c94c2abfe4ade142ab1d62c76724bce2 (diff)
Made removeIdenticalRules faster by using sortNubBy instead of nubBy.
Diffstat (limited to 'src/GF/Speech')
-rw-r--r--src/GF/Speech/TransformCFG.hs11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/GF/Speech/TransformCFG.hs b/src/GF/Speech/TransformCFG.hs
index 84feae845..d12d06628 100644
--- a/src/GF/Speech/TransformCFG.hs
+++ b/src/GF/Speech/TransformCFG.hs
@@ -5,9 +5,9 @@
-- Stability : (stable)
-- Portability : (portable)
--
--- > CVS $Date: 2005/09/14 15:17:30 $
+-- > CVS $Date: 2005/10/26 18:47:16 $
-- > CVS $Author: bringert $
--- > CVS $Revision: 1.22 $
+-- > CVS $Revision: 1.23 $
--
-- This module does some useful transformations on CFGs.
--
@@ -76,8 +76,11 @@ removeEmptyCats = fix removeEmptyCats'
-- | Remove rules which are identical, not caring about the rule names.
removeIdenticalRules :: CFRules -> CFRules
-removeIdenticalRules g = [(c,nubBy sameCatAndRhs rs) | (c,rs) <- g]
- where sameCatAndRhs (CFRule c1 ss1 _) (CFRule c2 ss2 _) = c1 == c2 && ss1 == ss2
+removeIdenticalRules g = [(c,sortNubBy compareCatAndRhs rs) | (c,rs) <- g]
+ where compareCatAndRhs (CFRule c1 ss1 _) (CFRule c2 ss2 _) =
+ case c1 `compare` c2 of
+ EQ -> ss1 `compare` ss2
+ o -> o
removeLeftRecursion :: CFRules -> CFRules
removeLeftRecursion rs = concatMap removeDirectLeftRecursion $ map handleProds rs