Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mincss
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Taddeüs Kroes
mincss
Commits
d36f52bf
Commit
d36f52bf
authored
10 years ago
by
Taddeüs Kroes
Browse files
Options
Downloads
Patches
Plain Diff
Implemented duplicate declaration pruning
parent
944d6cff
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Makefile
+2
-2
2 additions, 2 deletions
Makefile
duplicates.ml
+37
-0
37 additions, 0 deletions
duplicates.ml
main.ml
+1
-1
1 addition, 1 deletion
main.ml
with
40 additions
and
3 deletions
Makefile
+
2
−
2
View file @
d36f52bf
RESULT
:=
mincss
PRE_TGTS
:=
types
MODULES
:=
color_names util stringify parser lexer parse selector color
\
shorthand main
shorthand
duplicates
main
ALL_NAMES
:=
$(
PRE_TGTS
)
$(
MODULES
)
OCAMLCFLAGS
:=
-g
...
...
@@ -36,7 +36,7 @@ lexer.cmi: lexer.ml
parser.cmx
:
parser.cmi lexer.cmx
parser.mli
:
parser.ml
parse.cmx
:
lexer.cmi parser.cmx
main.cmx
:
parse.cmx util.cmx color.cmx shorthand.cmx
main.cmx
:
parse.cmx util.cmx color.cmx shorthand.cmx
duplicates.cmx
util.cmx
:
OCAMLCFLAGS += -pp cpp
util.cmx color.cmx
:
color_names.cmx
stringify.cmx parser.cmx color.cmx shorthand.cmx
:
util.cmi
...
...
This diff is collapsed.
Click to expand it.
duplicates.ml
0 → 100644
+
37
−
0
View file @
d36f52bf
open
Types
module
SM
=
Map
.
Make
(
String
)
let
prune_duplicates
decls
=
let
keep
=
Array
.
make
(
List
.
length
decls
)
true
in
let
rec
tag
db
index
=
function
|
(
name
,
_
,
imp
)
::
tl
when
SM
.
mem
name
db
->
(* previous value exists, one needs to be removed *)
let
prev_index
,
prev_imp
=
SM
.
find
name
db
in
if
not
imp
&&
prev_imp
then
begin
keep
.
(
index
)
<-
false
;
tag
db
(
index
+
1
)
tl
end
else
begin
keep
.
(
prev_index
)
<-
false
;
tag
(
SM
.
add
name
(
index
,
imp
)
db
)
(
index
+
1
)
tl
end
|
(
name
,
_
,
imp
)
::
tl
->
tag
(
SM
.
add
name
(
index
,
imp
)
db
)
(
index
+
1
)
tl
|
[]
->
()
in
tag
SM
.
empty
0
decls
;
let
rec
prune
i
=
function
|
[]
->
[]
|
hd
::
tl
when
keep
.
(
i
)
->
hd
::
prune
(
i
+
1
)
tl
|
_
::
tl
->
prune
(
i
+
1
)
tl
in
prune
0
decls
let
transform
=
function
|
Statement
(
Ruleset
(
selectors
,
decls
))
->
Statement
(
Ruleset
(
selectors
,
prune_duplicates
decls
))
|
v
->
v
let
compress
=
Util
.
transform_stylesheet
transform
This diff is collapsed.
Click to expand it.
main.ml
+
1
−
1
View file @
d36f52bf
...
...
@@ -136,7 +136,7 @@ let handle_args args =
(* unfold before pruning duplicates so that shorthand components are
* correctly pruned *)
|>
switch
args
.
shorthands
Shorthand
.
unfold_stylesheet
(*
|> switch args.duplicates Duplicates.compress
*)
|>
switch
args
.
duplicates
Duplicates
.
compress
|>
switch
args
.
shorthands
Shorthand
.
compress
in
let
output
=
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment