Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Alchemy Viewer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Silent mode is enabled
All outbound communications are blocked.
Learn more
.
Show more breadcrumbs
Alchemy Viewer
Alchemy Viewer
Commits
c211e075
Commit
c211e075
authored
3 years ago
by
Rye Mutt
Browse files
Options
Downloads
Patches
Plain Diff
Make LLSD moveable
parent
e2ba07bf
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
indra/llcommon/llsd.cpp
+26
-6
26 additions, 6 deletions
indra/llcommon/llsd.cpp
indra/llcommon/llsd.h
+10
-4
10 additions, 4 deletions
indra/llcommon/llsd.h
with
36 additions
and
10 deletions
indra/llcommon/llsd.cpp
+
26
−
6
View file @
c211e075
...
...
@@ -92,7 +92,10 @@ class LLSD::Impl
public
:
static
void
reset
(
Impl
*&
var
,
Impl
*
impl
);
///< safely set var to refer to the new impl (possibly shared)
static
void
move
(
Impl
*&
var
,
Impl
*&
impl
);
///< safely move impl from one object to another
static
Impl
&
safe
(
Impl
*
);
static
const
Impl
&
safe
(
const
Impl
*
);
///< since a NULL Impl* is used for undefined, this ensures there is
...
...
@@ -664,15 +667,30 @@ LLSD::Impl::~Impl()
void
LLSD
::
Impl
::
reset
(
Impl
*&
var
,
Impl
*
impl
)
{
if
(
impl
&&
impl
->
mUseCount
!=
STATIC_USAGE_COUNT
)
if
(
var
!=
impl
)
{
++
impl
->
mUseCount
;
if
(
impl
&&
impl
->
mUseCount
!=
STATIC_USAGE_COUNT
)
{
++
impl
->
mUseCount
;
}
if
(
var
&&
var
->
mUseCount
!=
STATIC_USAGE_COUNT
&&
--
var
->
mUseCount
==
0
)
{
delete
var
;
}
var
=
impl
;
}
if
(
var
&&
var
->
mUseCount
!=
STATIC_USAGE_COUNT
&&
--
var
->
mUseCount
==
0
)
}
void
LLSD
::
Impl
::
move
(
Impl
*&
var
,
Impl
*&
impl
)
{
if
(
var
==
impl
)
return
;
// Bail out var is impl
if
(
var
&&
var
->
mUseCount
!=
STATIC_USAGE_COUNT
&&
--
var
->
mUseCount
==
0
)
{
delete
var
;
delete
var
;
// destroy var if usage falls to 0 and not static
}
var
=
impl
;
var
=
impl
;
// Steal impl to var without incrementing use since this is a move
impl
=
nullptr
;
// null out old-impl pointer
}
LLSD
::
Impl
&
LLSD
::
Impl
::
safe
(
Impl
*
impl
)
...
...
@@ -824,6 +842,8 @@ LLSD::~LLSD() { FREE_LLSD_OBJECT; Impl::reset(impl, nullptr); }
LLSD
::
LLSD
(
const
LLSD
&
other
)
:
impl
(
nullptr
)
{
ALLOC_LLSD_OBJECT
;
assign
(
other
);
}
void
LLSD
::
assign
(
const
LLSD
&
other
)
{
Impl
::
assign
(
impl
,
other
.
impl
);
}
LLSD
::
LLSD
(
LLSD
&&
other
)
noexcept
:
impl
(
nullptr
)
{
ALLOC_LLSD_OBJECT
;
Impl
::
move
(
impl
,
other
.
impl
);
}
LLSD
&
LLSD
::
operator
=
(
LLSD
&&
other
)
noexcept
{
Impl
::
move
(
impl
,
other
.
impl
);
return
*
this
;
}
void
LLSD
::
clear
()
{
Impl
::
assignUndefined
(
impl
);
}
...
...
This diff is collapsed.
Click to expand it.
indra/llcommon/llsd.h
+
10
−
4
View file @
c211e075
...
...
@@ -147,7 +147,7 @@
// Normally undefined, used for diagnostics
//#define LLSD_DEBUG_INFO 1
class
LL_COMMON_API
LLSD
class
LL_COMMON_API
LLSD
final
{
public:
LLSD
();
///< initially Undefined
...
...
@@ -161,6 +161,12 @@ class LL_COMMON_API LLSD
//@}
/** @name Movable */
//@{
LLSD
(
LLSD
&&
other
)
noexcept
;
LLSD
&
operator
=
(
LLSD
&&
other
)
noexcept
;
//@}
void
clear
();
///< resets to Undefined
...
...
@@ -389,9 +395,9 @@ class LL_COMMON_API LLSD
using an arbitrary pointer or scalar type to std::string.
*/
//@{
LLSD
(
const
void
*
);
///< construct from aribrary pointers
void
assign
(
const
void
*
);
///< assign from arbitrary pointers
LLSD
&
operator
=
(
const
void
*
);
///< assign from arbitrary pointers
LLSD
(
const
void
*
)
=
delete
;
///< construct from aribrary pointers
void
assign
(
const
void
*
)
=
delete
;
///< assign from arbitrary pointers
LLSD
&
operator
=
(
const
void
*
)
=
delete
;
///< assign from arbitrary pointers
bool
has
(
Integer
)
const
;
///< has() only works for Maps
//@}
...
...
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