On Thu, 13 Feb 2025 at 18:02, Richard Kimberly Heck <rikih...@gmail.com>
wrote:

> On 2/13/25 5:59 AM, Jean-Marc Lasgouttes wrote:
> > commit b4a982e0229ea953d458a495e56e7362c6a3b78b
> > Author: Jean-Marc Lasgouttes <lasgout...@lyx.org>
> > Date:   Thu Feb 13 11:57:11 2025 +0100
> >
> >      avoid temporary variables (spotted by Coverity Scan)
> > ---
> >   src/LyXRC.cpp | 6 ++----
> >   1 file changed, 2 insertions(+), 4 deletions(-)
> >
> > diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp
> > index 4309fc41d4..966b2ce410 100644
> > --- a/src/LyXRC.cpp
> > +++ b/src/LyXRC.cpp
> > @@ -958,16 +958,14 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc,
> bool check_format)
> >               case RC_VIEWER_ALTERNATIVES:  {
> >                       string format, command;
> >                       if ((lexrc >> format) && lexrc.next(true)) {
> > -                             command  = lexrc.getString();
> > -
>  viewer_alternatives[format].insert(command);
> > +
>  viewer_alternatives[format].insert(lexrc.getString());
>
> Perhaps a compromise would be to include a comment, or even to leave it as:
>
> // command  = lexrc.getString();
> viewer_alternatives[format].insert(lexrc.getString());
>
> One could simply do this as such cases were fixed.
>

I understand that the problem that Coverity sees is a copy. We could avoid
that using std::string_view, new in C++17, I think: it's just a pointer to
a std::string that you can use more or less like a std::string (unlike a
pointer).
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
https://lists.lyx.org/mailman/listinfo/lyx-devel

Reply via email to