Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uniset2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UniSet project repositories
uniset2
Commits
f2d57bfe
Commit
f2d57bfe
authored
Jan 30, 2014
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Перенёс оптимизацию для ObjectIndex_idXML.h из 2.0, очень уж актуально.
parent
098c55eb
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
19 deletions
+23
-19
ObjectIndex_idXML.h
include/ObjectIndex_idXML.h
+6
-2
ObjectIndex_idXML.cc
src/ObjectRepository/ObjectIndex_idXML.cc
+17
-17
No files found.
include/ObjectIndex_idXML.h
View file @
f2d57bfe
...
...
@@ -26,12 +26,16 @@ class ObjectIndex_idXML:
protected
:
virtual
void
build
(
UniXML
&
xml
);
void
read_section
(
UniXML
&
xml
,
const
std
::
string
sec
);
void
read_nodes
(
UniXML
&
xml
,
const
std
::
string
sec
);
void
read_section
(
UniXML
&
xml
,
const
std
::
string
&
sec
);
void
read_nodes
(
UniXML
&
xml
,
const
std
::
string
&
sec
);
private
:
typedef
std
::
map
<
UniSetTypes
::
ObjectId
,
UniSetTypes
::
ObjectInfo
>
MapObjects
;
MapObjects
omap
;
// чтобы не хранить дублирующие структуры (ObjectInfo)
typedef
std
::
map
<
std
::
string
,
UniSetTypes
::
ObjectId
>
MapObjectKey
;
MapObjectKey
mok
;
// для обратного писка
};
// -----------------------------------------------------------------------------------------
#endif
src/ObjectRepository/ObjectIndex_idXML.cc
View file @
f2d57bfe
...
...
@@ -30,11 +30,9 @@ ObjectIndex_idXML::~ObjectIndex_idXML()
// -----------------------------------------------------------------------------------------
ObjectId
ObjectIndex_idXML
::
getIdByName
(
const
string
&
name
)
{
for
(
MapObjects
::
iterator
it
=
omap
.
begin
();
it
!=
omap
.
end
();
++
it
)
{
if
(
it
->
second
.
repName
==
name
)
return
it
->
second
.
id
;
}
MapObjectKey
::
iterator
it
=
mok
.
find
(
name
);
if
(
it
!=
mok
.
end
()
)
return
it
->
second
;
return
DefaultObjectId
;
}
...
...
@@ -88,7 +86,7 @@ void ObjectIndex_idXML::build(UniXML& xml)
read_nodes
(
xml
,
"nodes"
);
}
// ------------------------------------------------------------------------------------------
void
ObjectIndex_idXML
::
read_section
(
UniXML
&
xml
,
const
std
::
string
sec
)
void
ObjectIndex_idXML
::
read_section
(
UniXML
&
xml
,
const
std
::
string
&
sec
)
{
string
secRoot
=
xml
.
getProp
(
xml
.
findNode
(
xml
.
getFirstNode
(),
"RootSection"
),
"name"
);
if
(
secRoot
.
empty
()
)
...
...
@@ -150,20 +148,22 @@ void ObjectIndex_idXML::read_section( UniXML& xml, const std::string sec )
strcpy
(
inf
.
repName
,
name
.
c_str
()
);
// textname
string
textname
(
xml
.
getProp
(
it
,
"textname"
));
string
textname
(
it
.
getProp
(
"textname"
));
if
(
textname
.
empty
()
)
textname
=
xml
.
getProp
(
it
,
"name"
);
textname
=
it
.
getProp
(
"name"
);
inf
.
textName
=
new
char
[
textname
.
size
()
+
1
];
strcpy
(
inf
.
textName
,
textname
.
c_str
()
);
inf
.
data
=
(
void
*
)(
xmlNode
*
)(
it
);
omap
[
inf
.
id
]
=
inf
;
// omap[inf.id] = inf;
omap
.
insert
(
MapObjects
::
value_type
(
inf
.
id
,
inf
));
// omap[inf.id] = inf;
mok
.
insert
(
MapObjectKey
::
value_type
(
name
,
inf
.
id
));
// mok[name] = inf.id;
}
}
// ------------------------------------------------------------------------------------------
void
ObjectIndex_idXML
::
read_nodes
(
UniXML
&
xml
,
const
std
::
string
sec
)
void
ObjectIndex_idXML
::
read_nodes
(
UniXML
&
xml
,
const
std
::
string
&
sec
)
{
xmlNode
*
root
(
xml
.
findNode
(
xml
.
getFirstNode
(),
sec
)
);
if
(
!
root
)
...
...
@@ -216,7 +216,10 @@ void ObjectIndex_idXML::read_nodes( UniXML& xml, const std::string sec )
inf
.
data
=
(
void
*
)(
xmlNode
*
)(
it
);
omap
[
inf
.
id
]
=
inf
;
// omap[inf.id] = inf;
omap
.
insert
(
MapObjects
::
value_type
(
inf
.
id
,
inf
));
// omap[inf.id] = inf;
mok
.
insert
(
MapObjectKey
::
value_type
(
nodename
,
inf
.
id
)
);
// mok[name] = inf.id;
}
}
// ------------------------------------------------------------------------------------------
...
...
@@ -231,12 +234,9 @@ const ObjectInfo* ObjectIndex_idXML::getObjectInfo( const ObjectId id )
// ------------------------------------------------------------------------------------------
const
ObjectInfo
*
ObjectIndex_idXML
::
getObjectInfo
(
const
std
::
string
name
)
{
const
char
*
n
=
name
.
c_str
();
for
(
MapObjects
::
iterator
it
=
omap
.
begin
();
it
!=
omap
.
end
();
it
++
)
{
if
(
!
strcmp
(
it
->
second
.
repName
,
n
)
)
return
&
(
it
->
second
);
}
MapObjectKey
::
iterator
it
=
mok
.
find
(
name
);
if
(
it
!=
mok
.
end
()
)
return
getObjectInfo
(
it
->
second
);
return
NULL
;
}
...
...
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