Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
libcifpp
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
libcifpp
Commits
0e83bc31
Unverified
Commit
0e83bc31
authored
Jan 30, 2024
by
Maarten L. Hekkelman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some small optimisations
parent
75a5f796
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
16 deletions
+47
-16
include/cif++/condition.hpp
+1
-1
include/cif++/item.hpp
+42
-11
src/item.cpp
+2
-2
src/pdb/reconstruct.cpp
+2
-2
No files found.
include/cif++/condition.hpp
View file @
0e83bc31
...
@@ -370,7 +370,7 @@ namespace detail
...
@@ -370,7 +370,7 @@ namespace detail
{
{
key_equals_condition_impl
(
item
&&
i
)
key_equals_condition_impl
(
item
&&
i
)
:
m_item_name
(
i
.
name
())
:
m_item_name
(
i
.
name
())
,
m_value
(
i
.
value
())
,
m_value
(
std
::
forward
<
item
>
(
i
)
.
value
())
{
{
}
}
...
...
include/cif++/item.hpp
View file @
0e83bc31
...
@@ -120,8 +120,6 @@ class item
...
@@ -120,8 +120,6 @@ class item
if
(
r
.
ec
!=
std
::
errc
())
if
(
r
.
ec
!=
std
::
errc
())
throw
std
::
runtime_error
(
"Could not format number"
);
throw
std
::
runtime_error
(
"Could not format number"
);
assert
(
r
.
ptr
>=
buffer
and
r
.
ptr
<
buffer
+
sizeof
(
buffer
));
*
r
.
ptr
=
0
;
m_value
.
assign
(
buffer
,
r
.
ptr
-
buffer
);
m_value
.
assign
(
buffer
,
r
.
ptr
-
buffer
);
}
}
...
@@ -141,8 +139,6 @@ class item
...
@@ -141,8 +139,6 @@ class item
if
(
r
.
ec
!=
std
::
errc
())
if
(
r
.
ec
!=
std
::
errc
())
throw
std
::
runtime_error
(
"Could not format number"
);
throw
std
::
runtime_error
(
"Could not format number"
);
assert
(
r
.
ptr
>=
buffer
and
r
.
ptr
<
buffer
+
sizeof
(
buffer
));
*
r
.
ptr
=
0
;
m_value
.
assign
(
buffer
,
r
.
ptr
-
buffer
);
m_value
.
assign
(
buffer
,
r
.
ptr
-
buffer
);
}
}
...
@@ -158,8 +154,6 @@ class item
...
@@ -158,8 +154,6 @@ class item
if
(
r
.
ec
!=
std
::
errc
())
if
(
r
.
ec
!=
std
::
errc
())
throw
std
::
runtime_error
(
"Could not format number"
);
throw
std
::
runtime_error
(
"Could not format number"
);
assert
(
r
.
ptr
>=
buffer
and
r
.
ptr
<
buffer
+
sizeof
(
buffer
));
*
r
.
ptr
=
0
;
m_value
.
assign
(
buffer
,
r
.
ptr
-
buffer
);
m_value
.
assign
(
buffer
,
r
.
ptr
-
buffer
);
}
}
...
@@ -174,13 +168,22 @@ class item
...
@@ -174,13 +168,22 @@ class item
/// \brief constructor for an item with name \a name and as
/// \brief constructor for an item with name \a name and as
/// content value \a value
/// content value \a value
item
(
const
std
::
string_view
name
,
const
std
::
string_view
value
)
item
(
const
std
::
string_view
name
,
std
::
string_view
value
)
:
m_name
(
name
)
:
m_name
(
name
)
,
m_value
(
value
)
,
m_value
(
value
)
{
{
}
}
/// \brief constructor for an item with name \a name and as
/// \brief constructor for an item with name \a name and as
/// content value \a value
template
<
typename
T
,
std
::
enable_if_t
<
std
::
is_same_v
<
T
,
std
::
string
>
,
int
>
=
0
>
item
(
const
std
::
string_view
name
,
T
&&
value
)
:
m_name
(
name
)
,
m_value
(
std
::
move
(
value
))
{
}
/// \brief constructor for an item with name \a name and as
/// content the optional value \a value
/// content the optional value \a value
template
<
typename
T
>
template
<
typename
T
>
item
(
const
std
::
string_view
name
,
const
std
::
optional
<
T
>
&
value
)
item
(
const
std
::
string_view
name
,
const
std
::
optional
<
T
>
&
value
)
...
@@ -219,7 +222,8 @@ class item
...
@@ -219,7 +222,8 @@ class item
/** @endcond */
/** @endcond */
std
::
string_view
name
()
const
{
return
m_name
;
}
///< Return the name of the item
std
::
string_view
name
()
const
{
return
m_name
;
}
///< Return the name of the item
std
::
string_view
value
()
const
{
return
m_value
;
}
///< Return the value of the item
std
::
string_view
value
()
const
&
{
return
m_value
;
}
///< Return the value of the item
std
::
string
value
()
const
&&
{
return
std
::
move
(
m_value
);
}
///< Return the value of the item
/// \brief replace the content of the stored value with \a v
/// \brief replace the content of the stored value with \a v
void
value
(
std
::
string_view
v
)
{
m_value
=
v
;
}
void
value
(
std
::
string_view
v
)
{
m_value
=
v
;
}
...
@@ -363,8 +367,35 @@ struct item_handle
...
@@ -363,8 +367,35 @@ struct item_handle
template
<
typename
T
>
template
<
typename
T
>
item_handle
&
operator
=
(
const
T
&
value
)
item_handle
&
operator
=
(
const
T
&
value
)
{
{
item
v
{
""
,
value
};
assign_value
(
item
{
""
,
value
}.
value
());
assign_value
(
v
);
return
*
this
;
}
/**
* @brief Assign value @a value to the item referenced
*
* @tparam T Type of the value
* @param value The value
* @return reference to this item_handle
*/
template
<
typename
T
>
item_handle
&
operator
=
(
T
&&
value
)
{
assign_value
(
item
{
""
,
std
::
move
(
value
)
}.
value
());
return
*
this
;
}
/**
* @brief Assign value @a value to the item referenced
*
* @tparam T Type of the value
* @param value The value
* @return reference to this item_handle
*/
template
<
size_t
N
>
item_handle
&
operator
=
(
const
char
(
&
value
)[
N
])
{
assign_value
({
""
,
std
::
move
(
value
)
});
return
*
this
;
return
*
this
;
}
}
...
@@ -508,7 +539,7 @@ struct item_handle
...
@@ -508,7 +539,7 @@ struct item_handle
uint16_t
m_item_ix
;
uint16_t
m_item_ix
;
row_handle
&
m_row_handle
;
row_handle
&
m_row_handle
;
void
assign_value
(
const
item
&
value
);
void
assign_value
(
std
::
string_view
value
);
};
};
// So sad that older gcc implementations of from_chars did not support floats yet...
// So sad that older gcc implementations of from_chars did not support floats yet...
...
...
src/item.cpp
View file @
0e83bc31
...
@@ -52,10 +52,10 @@ std::string_view item_handle::text() const
...
@@ -52,10 +52,10 @@ std::string_view item_handle::text() const
return
{};
return
{};
}
}
void
item_handle
::
assign_value
(
const
item
&
v
)
void
item_handle
::
assign_value
(
std
::
string_view
value
)
{
{
assert
(
not
m_row_handle
.
empty
());
assert
(
not
m_row_handle
.
empty
());
m_row_handle
.
assign
(
m_item_ix
,
v
.
value
()
,
true
);
m_row_handle
.
assign
(
m_item_ix
,
v
alue
,
true
);
}
}
void
item_handle
::
swap
(
item_handle
&
b
)
void
item_handle
::
swap
(
item_handle
&
b
)
...
...
src/pdb/reconstruct.cpp
View file @
0e83bc31
...
@@ -325,7 +325,7 @@ void checkChemCompRecords(datablock &db)
...
@@ -325,7 +325,7 @@ void checkChemCompRecords(datablock &db)
items
.
emplace_back
(
item
{
"formula_weight"
,
compound
->
formula_weight
()
});
items
.
emplace_back
(
item
{
"formula_weight"
,
compound
->
formula_weight
()
});
if
(
not
items
.
empty
())
if
(
not
items
.
empty
())
chem_comp_entry
.
assign
(
std
::
move
(
items
)
);
chem_comp_entry
.
assign
(
items
);
}
}
}
}
}
}
...
@@ -412,7 +412,7 @@ void checkAtomRecords(datablock &db)
...
@@ -412,7 +412,7 @@ void checkAtomRecords(datablock &db)
items
.
emplace_back
(
item
{
"formula_weight"
,
compound
->
formula_weight
()
});
items
.
emplace_back
(
item
{
"formula_weight"
,
compound
->
formula_weight
()
});
if
(
not
items
.
empty
())
if
(
not
items
.
empty
())
chem_comp_entry
.
assign
(
std
::
move
(
items
)
);
chem_comp_entry
.
assign
(
items
);
}
}
if
(
is_peptide
and
not
has_seq_id
(
k
))
if
(
is_peptide
and
not
has_seq_id
(
k
))
...
...
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