Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
node-sass
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
楚学文
node-sass
Commits
42a50269
Commit
42a50269
authored
Apr 02, 2012
by
Aaron Leung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Working on refactoring/optimizing the node data structure.
parent
414e8f5f
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
20 deletions
+24
-20
context.hpp
context.hpp
+0
-1
document_parser.cpp
document_parser.cpp
+0
-0
node.cpp
node.cpp
+19
-15
node.hpp
node.hpp
+1
-1
values.hpp
values.hpp
+4
-3
No files found.
context.hpp
View file @
42a50269
...
@@ -35,7 +35,6 @@ namespace Sass {
...
@@ -35,7 +35,6 @@ namespace Sass {
struct
Context
{
struct
Context
{
Environment
global_env
;
Environment
global_env
;
vector
<
Node
>
pending
;
vector
<
char
*>
source_refs
;
vector
<
char
*>
source_refs
;
size_t
ref_count
;
size_t
ref_count
;
...
...
document_parser.cpp
View file @
42a50269
This diff is collapsed.
Click to expand it.
node.cpp
View file @
42a50269
...
@@ -18,9 +18,9 @@ namespace Sass {
...
@@ -18,9 +18,9 @@ namespace Sass {
{
{
Node
n
(
*
this
);
Node
n
(
*
this
);
if
(
has_children
)
{
if
(
has_children
)
{
n
.
content
s
.
children
=
new
vector
<
Node
>
;
n
.
content
.
children
=
new
vector
<
Node
>
;
++
allocations
;
++
allocations
;
n
.
content
s
.
children
->
reserve
(
size
());
n
.
content
.
children
->
reserve
(
size
());
for
(
int
i
=
0
;
i
<
size
();
++
i
)
{
for
(
int
i
=
0
;
i
<
size
();
++
i
)
{
n
<<
at
(
i
).
clone
();
n
<<
at
(
i
).
clone
();
}
}
...
@@ -149,8 +149,12 @@ namespace Sass {
...
@@ -149,8 +149,12 @@ namespace Sass {
stringstream
ss
;
stringstream
ss
;
// ss.setf(std::ios::fixed, std::ios::floatfield);
// ss.setf(std::ios::fixed, std::ios::floatfield);
// ss.precision(3);
// ss.precision(3);
ss
<<
content
.
dimension
.
numeric_value
ss
<<
content
.
dimension
.
numeric_value
;
<<
string
(
Token
(
content
.
dimension
.
unit
,
identifier
(
content
.
dimension
.
unit
)));
Token
unit
;
unit
.
begin
=
content
.
dimension
.
unit
;
unit
.
end
=
Prelexer
::
identifier
(
content
.
dimension
.
unit
);
ss
<<
string
(
unit
);
// << string(Token(content.dimension.unit, Prelexer::identifier(content.dimension.unit)));
return
ss
.
str
();
return
ss
.
str
();
}
break
;
}
break
;
...
@@ -218,7 +222,7 @@ namespace Sass {
...
@@ -218,7 +222,7 @@ namespace Sass {
string
indentation
(
2
*
depth
,
' '
);
string
indentation
(
2
*
depth
,
' '
);
switch
(
type
)
{
switch
(
type
)
{
case
comment
:
case
comment
:
buf
<<
indentation
<<
string
(
token
)
<<
endl
;
buf
<<
indentation
<<
string
(
content
.
token
)
<<
endl
;
break
;
break
;
case
ruleset
:
case
ruleset
:
buf
<<
indentation
;
buf
<<
indentation
;
...
@@ -238,8 +242,8 @@ namespace Sass {
...
@@ -238,8 +242,8 @@ namespace Sass {
}
}
break
;
break
;
case
selector_combinator
:
case
selector_combinator
:
if
(
std
::
isspace
(
token
.
begin
[
0
]))
buf
<<
' '
;
if
(
std
::
isspace
(
content
.
token
.
begin
[
0
]))
buf
<<
' '
;
else
buf
<<
' '
<<
string
(
token
)
<<
' '
;
else
buf
<<
' '
<<
string
(
content
.
token
)
<<
' '
;
break
;
break
;
case
simple_selector_sequence
:
case
simple_selector_sequence
:
for
(
int
i
=
0
;
i
<
size
();
++
i
)
{
for
(
int
i
=
0
;
i
<
size
();
++
i
)
{
...
@@ -247,7 +251,7 @@ namespace Sass {
...
@@ -247,7 +251,7 @@ namespace Sass {
}
}
break
;
break
;
case
simple_selector
:
case
simple_selector
:
buf
<<
string
(
token
);
buf
<<
string
(
content
.
token
);
break
;
break
;
case
block
:
case
block
:
buf
<<
" {"
<<
endl
;
buf
<<
" {"
<<
endl
;
...
@@ -262,13 +266,13 @@ namespace Sass {
...
@@ -262,13 +266,13 @@ namespace Sass {
buf
<<
';'
<<
endl
;
buf
<<
';'
<<
endl
;
break
;
break
;
case
property
:
case
property
:
buf
<<
string
(
token
);
buf
<<
string
(
content
.
token
);
break
;
break
;
case
values
:
case
values
:
for
(
int
i
=
0
;
i
<
size
();
at
(
i
++
).
echo
(
buf
,
depth
))
;
for
(
int
i
=
0
;
i
<
size
();
at
(
i
++
).
echo
(
buf
,
depth
))
;
break
;
break
;
case
value
:
case
value
:
buf
<<
' '
<<
string
(
token
);
buf
<<
' '
<<
string
(
content
.
token
);
break
;
break
;
}
}
}
}
...
@@ -434,13 +438,13 @@ namespace Sass {
...
@@ -434,13 +438,13 @@ namespace Sass {
if
(
at
(
i
).
type
==
expansion
)
{
if
(
at
(
i
).
type
==
expansion
)
{
Node
expn
=
at
(
i
);
Node
expn
=
at
(
i
);
if
(
expn
[
0
].
has_expansions
)
expn
.
flatten
();
if
(
expn
[
0
].
has_expansions
)
expn
.
flatten
();
at
(
0
).
has_rules_or_comments
|=
expn
[
0
].
has_rules_or_comments
;
at
(
0
).
has_statements
|=
expn
[
0
].
has_statements
;
at
(
0
).
has_rulesets
|=
expn
[
0
].
has_rulesets
;
at
(
0
).
has_blocks
|=
expn
[
0
].
has_blocks
;
at
(
0
).
has_propsets
|=
expn
[
0
].
has_propsets
;
at
(
0
).
has_expansions
|=
expn
[
0
].
has_expansions
;
at
(
0
).
has_expansions
|=
expn
[
0
].
has_expansions
;
at
(
i
).
type
=
none
;
at
(
i
).
type
=
none
;
children
->
insert
(
children
->
begin
()
+
i
,
content
.
children
->
insert
(
content
.
children
->
begin
()
+
i
,
expn
.
children
->
begin
(),
expn
.
children
->
end
());
expn
.
content
.
children
->
begin
(),
expn
.
content
.
children
->
end
());
}
}
}
}
}
}
...
...
node.hpp
View file @
42a50269
...
@@ -54,7 +54,7 @@ namespace Sass {
...
@@ -54,7 +54,7 @@ namespace Sass {
textual_dimension
,
textual_dimension
,
textual_number
,
textual_number
,
textual_hex
,
textual_hex
,
color_name
;
color_name
,
string_constant
,
string_constant
,
numeric_percentage
,
numeric_percentage
,
numeric_dimension
,
numeric_dimension
,
...
...
values.hpp
View file @
42a50269
...
@@ -9,8 +9,8 @@ namespace Sass {
...
@@ -9,8 +9,8 @@ namespace Sass {
const
char
*
begin
;
const
char
*
begin
;
const
char
*
end
;
const
char
*
end
;
Token
();
//
Token();
Token
(
const
char
*
begin
,
const
char
*
end
);
//
Token(const char* begin, const char* end);
size_t
length
()
const
size_t
length
()
const
{
return
end
-
begin
;
}
{
return
end
-
begin
;
}
...
@@ -29,7 +29,7 @@ namespace Sass {
...
@@ -29,7 +29,7 @@ namespace Sass {
};
};
struct
Dimension
{
struct
Dimension
{
const
double
numeric_value
;
double
numeric_value
;
const
char
*
unit
;
const
char
*
unit
;
};
};
}
}
\ No newline at end of file
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