Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mincss
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
mincss
Commits
d36f52bf
Commit
d36f52bf
authored
Oct 01, 2014
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented duplicate declaration pruning
parent
944d6cff
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
3 deletions
+40
-3
Makefile
Makefile
+2
-2
duplicates.ml
duplicates.ml
+37
-0
main.ml
main.ml
+1
-1
No files found.
Makefile
View file @
d36f52bf
RESULT
:=
mincss
RESULT
:=
mincss
PRE_TGTS
:=
types
PRE_TGTS
:=
types
MODULES
:=
color_names util stringify parser lexer parse selector color
\
MODULES
:=
color_names util stringify parser lexer parse selector color
\
shorthand main
shorthand
duplicates
main
ALL_NAMES
:=
$(PRE_TGTS)
$(MODULES)
ALL_NAMES
:=
$(PRE_TGTS)
$(MODULES)
OCAMLCFLAGS
:=
-g
OCAMLCFLAGS
:=
-g
...
@@ -36,7 +36,7 @@ lexer.cmi: lexer.ml
...
@@ -36,7 +36,7 @@ lexer.cmi: lexer.ml
parser.cmx
:
parser.cmi lexer.cmx
parser.cmx
:
parser.cmi lexer.cmx
parser.mli
:
parser.ml
parser.mli
:
parser.ml
parse.cmx
:
lexer.cmi parser.cmx
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
:
OCAMLCFLAGS += -pp cpp
util.cmx color.cmx
:
color_names.cmx
util.cmx color.cmx
:
color_names.cmx
stringify.cmx parser.cmx color.cmx shorthand.cmx
:
util.cmi
stringify.cmx parser.cmx color.cmx shorthand.cmx
:
util.cmi
...
...
duplicates.ml
0 → 100644
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
main.ml
View file @
d36f52bf
...
@@ -136,7 +136,7 @@ let handle_args args =
...
@@ -136,7 +136,7 @@ let handle_args args =
(* unfold before pruning duplicates so that shorthand components are
(* unfold before pruning duplicates so that shorthand components are
* correctly pruned *)
* correctly pruned *)
|>
switch
args
.
shorthands
Shorthand
.
unfold_stylesheet
|>
switch
args
.
shorthands
Shorthand
.
unfold_stylesheet
(*|> switch args.duplicates Duplicates.compress*)
|>
switch
args
.
duplicates
Duplicates
.
compress
|>
switch
args
.
shorthands
Shorthand
.
compress
|>
switch
args
.
shorthands
Shorthand
.
compress
in
in
let
output
=
let
output
=
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment