Commit df763d79 authored by Adam Langley's avatar Adam Langley Committed by Commit Bot

webauth: fix comment and save some copies.

jyasskin notes in [1] that the CTAP rules for sorting map entries are
slightly different than the suggestions in the RFC. This change
highlights that difference in the comment.

Additionally, by using StringPiece, some copies can be eliminated.

[1] https://chromium-review.googlesource.com/716573

Change-Id: Ida2687dde4036058613cb060e738fd9484deae02
Bug: None
Reviewed-on: https://chromium-review.googlesource.com/775473
Commit-Queue: Adam Langley <agl@chromium.org>
Reviewed-by: default avatarJeffrey Yasskin <jyasskin@chromium.org>
Reviewed-by: default avatarBalazs Engedy <engedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#519785}
parent 53479ca9
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include "base/containers/flat_map.h" #include "base/containers/flat_map.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/strings/string_piece_forward.h" #include "base/strings/string_piece.h"
#include "content/common/content_export.h" #include "content/common/content_export.h"
namespace content { namespace content {
...@@ -37,22 +37,21 @@ class CONTENT_EXPORT CBORValue { ...@@ -37,22 +37,21 @@ class CONTENT_EXPORT CBORValue {
// (byte-wise) lexical order sorts earlier. // (byte-wise) lexical order sorts earlier.
// //
// See section 6 of https://fidoalliance.org/specs/fido-v2.0-rd-20170927/ // See section 6 of https://fidoalliance.org/specs/fido-v2.0-rd-20170927/
// fido-client-to-authenticator-protocol-v2.0-rd-20170927.html and // fido-client-to-authenticator-protocol-v2.0-rd-20170927.html.
// https://tools.ietf.org/html/rfc7049#section-3.9 also. //
bool operator()(const std::string& a, const std::string& b) const { // The sort order defined in
// https://tools.ietf.org/html/rfc7049#section-3.9 is similar to the CTAP
// order implemented here, but it sorts purely by serialised key and
// doesn't specify that major types are compared first. Thus the shortest
// key sorts first by the RFC rules (irrespective of the major type), but
// may not by CTAP rules.
bool operator()(const base::StringPiece& a,
const base::StringPiece& b) const {
const size_t a_size = a.size(); const size_t a_size = a.size();
const size_t b_size = b.size(); const size_t b_size = b.size();
return std::tie(a_size, a) < std::tie(b_size, b); return std::tie(a_size, a) < std::tie(b_size, b);
} }
bool operator()(const char* a, const std::string& b) const {
return operator()(std::string(a), b);
}
bool operator()(const std::string& a, const char* b) const {
return operator()(a, std::string(b));
}
using is_transparent = void; using is_transparent = void;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment