Page MenuHome

Cleanup: Use raw string literal
ClosedPublic

Authored by Sergey Sharybin (sergey) on Feb 5 2021, 2:09 PM.

Details

Summary

Resolves modernize-raw-string-literal Clang-Tidy warning

The way warning works is it suggests to use raw literal when
overhead of having escape characters is higher than the overhead
of having raw literal syntax (talking about code size overhead).
This means that the warning will not trigger for "foo\"bar".

Not sure if this is something we really find better. Input is
welcome!

Diff Detail

Repository
rB Blender
Branch
modernize_raw_string_literal (branched from master)
Build Status
Buildable 12652
Build 12652: arc lint + arc unit

Event Timeline

Sergey Sharybin (sergey) requested review of this revision.Feb 5 2021, 2:09 PM
Sergey Sharybin (sergey) created this revision.
This revision is now accepted and ready to land.Feb 5 2021, 2:59 PM

I really don't see the need for this in HTML code. HTML can use both single and double quotes for arguments, so why not just use something like this?

f << "<line fill='none' stroke='black' stroke-width='" << strokew << "' x1='"
  << SX(uco[0]) << "' y1='" << SY(uco[1]) << "' x2='" << SX(vco[0]) << "' y2='"
  << SY(vco[1]) << "'>\n";

"\\\\\\"R"(\\\)" is a clear winner though!

Wasn't there something in the strict HTML that it should be double quote? Is also not really HTML, but some gnuplot/graphviz dialect. You sure it works there?

Is also from code cleanup point of view: doing those type of changes (" -> ') is not something I can call no-functional-changes as it changes the way Blender saves files. Not sure this is something I want to be looking into. But having R"(\\\)" and the warning enabled is something I want to.

Even in the good old HTML 4 it was allowed to use either double or single quotes, to make it easier to have attribute values that have the other style of quotes in their value. See HTML 4 spec on SGML section 3.2.2.

You're right to worry about graphviz, though. From their documentation:

Each of the HTML elements has a set of optional attributes. Attribute values must appear in double quotes.

So yeah, your patch is doing the right thing here.

This revision was automatically updated to reflect the committed changes.