Skip to content

Commit

Permalink
Misc cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentlb committed Jan 13, 2022
1 parent 3ac5816 commit 57d1ebd
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 10 deletions.
1 change: 0 additions & 1 deletion Shader Minifier.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
<None Include="App.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<Content Include="OpenTK.dll.config" />
</ItemGroup>
<ItemGroup>
<Reference Include="Argu">
Expand Down
1 change: 0 additions & 1 deletion src/options.fs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module Options

open System.Collections.Generic
open System.IO
open Argu

Expand Down
8 changes: 4 additions & 4 deletions src/parse.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 1 addition & 4 deletions src/renamer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down

0 comments on commit 57d1ebd

Please sign in to comment.