Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Main Repositories
otb
Commits
6eafacb5
Commit
6eafacb5
authored
Oct 16, 2020
by
Cédric Traizet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
PERF: use hidden friend idiom pattern when overloading operator== (code review)
parent
3825e8cf
Pipeline
#5962
passed with stages
in 180 minutes and 1 second
Changes
5
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
51 deletions
+40
-51
Modules/Core/Metadata/include/otbGeometryMetadata.h
Modules/Core/Metadata/include/otbGeometryMetadata.h
+19
-3
Modules/Core/Metadata/include/otbMetaDataKey.h
Modules/Core/Metadata/include/otbMetaDataKey.h
+21
-11
Modules/Core/Metadata/src/otbGeometryMetadata.cxx
Modules/Core/Metadata/src/otbGeometryMetadata.cxx
+0
-18
Modules/Core/Metadata/src/otbMetaDataKey.cxx
Modules/Core/Metadata/src/otbMetaDataKey.cxx
+0
-18
Modules/IO/TestKernel/src/otbTestHelper.cxx
Modules/IO/TestKernel/src/otbTestHelper.cxx
+0
-1
No files found.
Modules/Core/Metadata/include/otbGeometryMetadata.h
View file @
6eafacb5
...
...
@@ -161,12 +161,28 @@ struct OTBMetadata_EXPORT RPCParam
oss
<<
"]"
;
return
oss
.
str
();
};
// Equality comparison operator (hidden friend idiom)
friend
bool
operator
==
(
const
RPCParam
&
lhs
,
const
RPCParam
&
rhs
)
{
return
lhs
.
LineOffset
==
rhs
.
LineOffset
&&
lhs
.
SampleOffset
==
rhs
.
SampleOffset
&&
lhs
.
LatOffset
==
rhs
.
LatOffset
&&
lhs
.
LonOffset
==
rhs
.
LonOffset
&&
lhs
.
HeightOffset
==
rhs
.
HeightOffset
&&
lhs
.
LineScale
==
rhs
.
LineScale
&&
lhs
.
SampleScale
==
rhs
.
SampleScale
&&
lhs
.
LatScale
==
rhs
.
LatScale
&&
lhs
.
LonScale
==
rhs
.
LonScale
&&
lhs
.
HeightScale
==
rhs
.
HeightScale
&&
std
::
equal
(
std
::
begin
(
lhs
.
LineNum
),
std
::
end
(
lhs
.
LineNum
),
std
::
begin
(
rhs
.
LineNum
))
&&
std
::
equal
(
std
::
begin
(
lhs
.
LineDen
),
std
::
end
(
lhs
.
LineDen
),
std
::
begin
(
rhs
.
LineDen
))
&&
std
::
equal
(
std
::
begin
(
lhs
.
SampleNum
),
std
::
end
(
lhs
.
SampleNum
),
std
::
begin
(
rhs
.
SampleNum
))
&&
std
::
equal
(
std
::
begin
(
lhs
.
SampleDen
),
std
::
end
(
lhs
.
SampleDen
),
std
::
begin
(
rhs
.
SampleDen
));
}
};
OTBMetadata_EXPORT
bool
operator
==
(
const
RPCParam
&
lhs
,
const
RPCParam
&
rhs
);
}
// end namespace Projection
}
// end namespace otb
...
...
Modules/Core/Metadata/include/otbMetaDataKey.h
View file @
6eafacb5
...
...
@@ -238,9 +238,14 @@ struct OTBMetadata_EXPORT Time : tm
friend
OTBMetadata_EXPORT
std
::
istream
&
operator
>>
(
std
::
istream
&
is
,
Time
&
val
);
friend
OTBMetadata_EXPORT
bool
operator
==
(
const
Time
&
lhs
,
const
Time
&
rhs
)
{
tm
tmLhs
=
lhs
;
tm
tmRhs
=
rhs
;
return
mktime
(
&
tmLhs
)
+
lhs
.
frac_sec
==
mktime
(
&
tmRhs
)
+
rhs
.
frac_sec
;
}
};
OTBMetadata_EXPORT
bool
operator
==
(
const
Time
&
lhs
,
const
Time
&
rhs
);
struct
LUTAxis
{
...
...
@@ -254,10 +259,15 @@ struct LUTAxis
std
::
vector
<
double
>
Values
;
/** Export to JSON */
std
::
string
ToJSON
(
bool
multiline
=
false
)
const
;
};
OTBMetadata_EXPORT
bool
operator
==
(
const
LUTAxis
&
lhs
,
const
LUTAxis
&
rhs
);
friend
bool
operator
==
(
const
LUTAxis
&
lhs
,
const
LUTAxis
&
rhs
)
{
return
lhs
.
Size
==
rhs
.
Size
&&
lhs
.
Origin
==
rhs
.
Origin
&&
lhs
.
Spacing
==
rhs
.
Spacing
&&
lhs
.
Values
==
rhs
.
Values
;
}
};
template
<
unsigned
int
VDim
>
class
LUT
{
...
...
@@ -271,14 +281,14 @@ public:
std
::
string
OTBMetadata_EXPORT
ToString
()
const
;
void
OTBMetadata_EXPORT
FromString
(
std
::
string
);
};
template
<
unsigned
int
VDim
>
bool
operator
==
(
const
LUT
<
VDim
>
&
lhs
,
const
LUT
<
VDim
>
&
rhs
)
{
return
std
::
equal
(
std
::
begin
(
lhs
.
Array
),
std
::
end
(
lhs
.
Array
),
std
::
begin
(
rhs
.
Array
)
)
&&
lhs
.
Array
==
rhs
.
Array
;
}
friend
bool
operator
==
(
const
LUT
<
VDim
>
&
lhs
,
const
LUT
<
VDim
>
&
rhs
)
{
return
std
::
equal
(
std
::
begin
(
lhs
.
Array
),
std
::
end
(
lhs
.
Array
),
std
::
begin
(
rhs
.
Array
)
)
&&
lhs
.
Array
==
rhs
.
Array
;
}
};
template
<
unsigned
int
VDim
>
...
...
Modules/Core/Metadata/src/otbGeometryMetadata.cxx
View file @
6eafacb5
...
...
@@ -107,23 +107,5 @@ std::string RPCParam::ToJSON(bool multiline) const
return
oss
.
str
();
}
bool
operator
==
(
const
RPCParam
&
lhs
,
const
RPCParam
&
rhs
)
{
return
lhs
.
LineOffset
==
rhs
.
LineOffset
&&
lhs
.
SampleOffset
==
rhs
.
SampleOffset
&&
lhs
.
LatOffset
==
rhs
.
LatOffset
&&
lhs
.
LonOffset
==
rhs
.
LonOffset
&&
lhs
.
HeightOffset
==
rhs
.
HeightOffset
&&
lhs
.
LineScale
==
rhs
.
LineScale
&&
lhs
.
SampleScale
==
rhs
.
SampleScale
&&
lhs
.
LatScale
==
rhs
.
LatScale
&&
lhs
.
LonScale
==
rhs
.
LonScale
&&
lhs
.
HeightScale
==
rhs
.
HeightScale
&&
std
::
equal
(
lhs
.
LineNum
,
lhs
.
LineNum
+
20
,
rhs
.
LineNum
)
&&
std
::
equal
(
lhs
.
LineDen
,
lhs
.
LineDen
+
20
,
rhs
.
LineDen
)
&&
std
::
equal
(
lhs
.
SampleNum
,
lhs
.
SampleNum
+
20
,
rhs
.
SampleNum
)
&&
std
::
equal
(
lhs
.
SampleDen
,
lhs
.
SampleDen
+
20
,
rhs
.
SampleDen
);
}
}
// end namespace Projection
}
// end namespace otb
Modules/Core/Metadata/src/otbMetaDataKey.cxx
View file @
6eafacb5
...
...
@@ -188,15 +188,6 @@ std::istream& operator>>(std::istream& is, Time& val)
#undef _OTB_ISTREAM_EXPECT
bool
operator
==
(
const
Time
&
lhs
,
const
Time
&
rhs
)
{
tm
tmLhs
=
lhs
;
tm
tmRhs
=
rhs
;
return
mktime
(
&
tmLhs
)
+
lhs
.
frac_sec
==
mktime
(
&
tmRhs
)
+
rhs
.
frac_sec
;
}
std
::
string
LUTAxis
::
ToJSON
(
bool
multiline
)
const
{
std
::
ostringstream
oss
;
...
...
@@ -404,15 +395,6 @@ MDGeomBmType MDGeomNames = bimapGenerator<MDGeom>(std::map<MDGeom, std::string>
{
MDGeom
::
Adjustment
,
"Adjustment"
}
});
OTBMetadata_EXPORT
bool
operator
==
(
const
LUTAxis
&
lhs
,
const
LUTAxis
&
rhs
)
{
return
lhs
.
Size
==
rhs
.
Size
&&
lhs
.
Origin
==
rhs
.
Origin
&&
lhs
.
Spacing
==
rhs
.
Spacing
&&
lhs
.
Values
==
rhs
.
Values
;
}
template
<
>
std
::
string
EnumToString
(
MDGeom
value
)
{
...
...
Modules/IO/TestKernel/src/otbTestHelper.cxx
View file @
6eafacb5
...
...
@@ -1456,7 +1456,6 @@ int CompareMetadataDict( const MapType & baselineMap,
while
(
first1
!=
last1
)
{
if
(
std
::
find
(
untestedKeys
.
begin
(),
untestedKeys
.
end
(),
first1
->
first
)
==
untestedKeys
.
end
())
//if (first1->first != untestedKeys)
{
if
(
first1
->
first
!=
first2
->
first
)
{
...
...
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