@@ -35,10 +35,10 @@ using namespace Exiv2::Internal;
3535constexpr auto dosEpsSignature = std::string_view(" \xC5\xD0\xD3\xC6 " );
3636
3737// first line of EPS
38- constexpr std::string_view epsFirstLine[] = {
39- " %!PS-Adobe-3.0 EPSF-3.0" ,
40- " %!PS-Adobe-3.0 EPSF-3.0 " , // OpenOffice
41- " %!PS-Adobe-3.1 EPSF-3.0" , // Illustrator
38+ constexpr std::array epsFirstLine{
39+ std::string_view ( " %!PS-Adobe-3.0 EPSF-3.0" ) ,
40+ std::string_view ( " %!PS-Adobe-3.0 EPSF-3.0 " ) , // OpenOffice
41+ std::string_view ( " %!PS-Adobe-3.1 EPSF-3.0" ) , // Illustrator
4242};
4343
4444// blank EPS file
@@ -315,7 +315,8 @@ void readWriteEpsMetadata(BasicIo& io, std::string& xmpPacket, NativePreviewList
315315#ifdef DEBUG
316316 EXV_DEBUG << " readWriteEpsMetadata: First line: " << firstLine << " \n " ;
317317#endif
318- if (!Exiv2::find (epsFirstLine, firstLine)) {
318+ auto it = std::find (epsFirstLine.begin (), epsFirstLine.end (), firstLine);
319+ if (it == epsFirstLine.end ()) {
319320 throw Error (ErrorCode::kerNotAnImage, " EPS" );
320321 }
321322
@@ -1118,10 +1119,10 @@ Image::UniquePtr newEpsInstance(BasicIo::UniquePtr io, bool create) {
11181119
11191120bool isEpsType (BasicIo& iIo, bool advance) {
11201121 // read as many bytes as needed for the longest (DOS) EPS signature
1121- size_t bufSize = dosEpsSignature. size ();
1122- for ( auto && i : epsFirstLine ) {
1123- bufSize = std::max (bufSize, i. size () );
1124- }
1122+ constexpr auto bufSize = [] {
1123+ auto f = []( const auto & a, const auto & b ) { return a. size () < b. size (); };
1124+ return std::max_element (epsFirstLine. begin (), epsFirstLine. end (), f)-> size ( );
1125+ }();
11251126 const size_t restore = iIo.tell (); // save
11261127 DataBuf buf = iIo.read (bufSize);
11271128 if (iIo.error () || buf.size () != bufSize) {
0 commit comments