From 57d1ebd0d85a14e3cdf35316d8bad1eb99a627e9 Mon Sep 17 00:00:00 2001 From: Laurent Le Brun Date: Thu, 13 Jan 2022 22:51:35 +0100 Subject: [PATCH] Misc cleanup --- Shader Minifier.fsproj | 1 - src/options.fs | 1 - src/parse.fs | 8 ++++---- src/renamer.fs | 5 +---- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/Shader Minifier.fsproj b/Shader Minifier.fsproj index aed65c76..1559ad85 100644 --- a/Shader Minifier.fsproj +++ b/Shader Minifier.fsproj @@ -61,7 +61,6 @@ Always - diff --git a/src/options.fs b/src/options.fs index 7fa4f43d..683bcf31 100644 --- a/src/options.fs +++ b/src/options.fs @@ -1,6 +1,5 @@ module Options -open System.Collections.Generic open System.IO open Argu diff --git a/src/parse.fs b/src/parse.fs index 20958676..6a2e4aed 100644 --- a/src/parse.fs +++ b/src/parse.fs @@ -127,7 +127,7 @@ module private ParseImpl = ] // Add all the operators in the OperatorParser - let makeOperator = + let () = // we start with operators with highest priority, then we decrement the counter. let mutable precCounter = 20 //(we have at most 20 different priorities) let addInfix li = @@ -164,9 +164,9 @@ module private ParseImpl = // Restriction on field names let check ((_,l) as arg : Ast.Decl) = - List.iter (fun (decl:Ast.DeclElt) -> + for decl in l do if decl.name.Name <> Rewriter.renameField decl.name.Name then - failwithf "Record field name '%s' is not allowed by Shader Minifier,\nbecause it looks like a vec4 field name." decl.name.Name) l + failwithf "Record field name '%s' is not allowed by Shader Minifier,\nbecause it looks like a vec4 field name." decl.name.Name arg let decls = many (declaration .>> ch ';' |>> check) @@ -280,7 +280,7 @@ module private ParseImpl = let list = many statement |>> Ast.Block between (ch '{') (ch '}') list - let mutable private forbiddenNames = [ "if"; "in"; "do" ] + let mutable private forbiddenNames = [] let macro = let nl = skipComment >>. skipMany (pchar '\\' >>. newline) diff --git a/src/renamer.fs b/src/renamer.fs index 9884f728..38375e79 100644 --- a/src/renamer.fs +++ b/src/renamer.fs @@ -53,14 +53,11 @@ module private RenamerImpl = let computeContextTable text = let contextTable = new HashMultiMap<(char*char), int>(HashIdentity.Structural) - Seq.pairwise text |> Seq.iter (fun (prev, next) -> + for prev, next in Seq.pairwise text do match contextTable.TryFind (prev, next) with | Some n -> contextTable.[(prev, next)] <- n + 1 | None -> contextTable.[(prev, next)] <- 1 - ) contextTable - //let chars, n = Seq.maxBy snd [for pair in contextTable -> pair.Key, pair.Value] - //printfn "max occ: %A -> %d" chars n // /!\ This function is a performance bottleneck. let chooseIdent (contextTable: HashMultiMap<(char*char), int>) ident candidates =