File tree Expand file tree Collapse file tree 2 files changed +10
-18
lines changed Expand file tree Collapse file tree 2 files changed +10
-18
lines changed Original file line number Diff line number Diff line change @@ -32,12 +32,11 @@ namespace Sass {
32
32
bool SharedObj::taint = false ;
33
33
34
34
SharedObj::SharedObj ()
35
- : detached( false )
35
+ : refcounter( 0 )
36
36
#ifdef DEBUG_SHARED_PTR
37
37
, dbg(false )
38
38
#endif
39
39
{
40
- refcounter = 0 ;
41
40
#ifdef DEBUG_SHARED_PTR
42
41
if (taint) all.push_back (this );
43
42
#endif
@@ -63,17 +62,14 @@ namespace Sass {
63
62
// AST_Node_Ptr ast = dynamic_cast<AST_Node*>(node);
64
63
if (node->dbg ) std::cerr << " DELETE NODE " << node << " \n " ;
65
64
#endif
66
- if (!node->detached ) {
67
- delete (node);
68
- }
65
+ delete (node);
69
66
}
70
67
}
71
68
}
72
69
73
70
void SharedPtr::incRefCount () {
74
71
if (node) {
75
72
++ node->refcounter ;
76
- node->detached = false ;
77
73
#ifdef DEBUG_SHARED_PTR
78
74
if (node->dbg ) {
79
75
std::cerr << " + " << node << " X " << node->refcounter << " (" << this << " ) " << " \n " ;
@@ -111,4 +107,4 @@ namespace Sass {
111
107
incRefCount ();
112
108
}
113
109
114
- }
110
+ }
Original file line number Diff line number Diff line change @@ -49,8 +49,6 @@ namespace Sass {
49
49
#endif
50
50
static bool taint;
51
51
long refcounter;
52
- // long refcount;
53
- bool detached;
54
52
#ifdef DEBUG_SHARED_PTR
55
53
bool dbg;
56
54
#endif
@@ -82,7 +80,7 @@ namespace Sass {
82
80
virtual const std::string to_string () const = 0;
83
81
84
82
virtual ~SharedObj ();
85
- long getRefCount () {
83
+ long getRefCount () const {
86
84
return refcounter;
87
85
}
88
86
};
@@ -123,11 +121,10 @@ namespace Sass {
123
121
bool isNull () const {
124
122
return node == NULL ;
125
123
};
126
- SharedObj* detach () const {
127
- if (node) {
128
- node->detached = true ;
129
- }
130
- return node;
124
+ SharedObj* detach () {
125
+ SharedObj* result = node;
126
+ node = NULL ;
127
+ return result;
131
128
};
132
129
operator bool () const {
133
130
return node != NULL ;
@@ -197,8 +194,7 @@ namespace Sass {
197
194
T* ptr () const {
198
195
return static_cast <T*>(this ->obj ());
199
196
};
200
- T* detach () const {
201
- if (this ->obj () == NULL ) return NULL ;
197
+ T* detach () {
202
198
return static_cast <T*>(SharedPtr::detach ());
203
199
}
204
200
bool isNull () const {
@@ -214,4 +210,4 @@ namespace Sass {
214
210
215
211
}
216
212
217
- #endif
213
+ #endif
You can’t perform that action at this time.
0 commit comments