summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElliott Hughes2017-11-30 18:31:35 -0600
committerElliott Hughes2017-11-30 18:32:15 -0600
commite805883a2b088a187ce4339e04387efbeb35b512 (patch)
tree0a31d7e95a62086d1d60f40fe09803d5c2adb6de
parentaaa0bbce8eadf1a428493f3524066a74447eded4 (diff)
downloadplatform-system-core-e805883a2b088a187ce4339e04387efbeb35b512.tar.gz
platform-system-core-e805883a2b088a187ce4339e04387efbeb35b512.tar.xz
platform-system-core-e805883a2b088a187ce4339e04387efbeb35b512.zip
std::string_view is no longer experimental.
Bug: N/A Test: builds Change-Id: I8f022fdc3ebaebd8aa250414569485a752f98da7
-rw-r--r--liblog/event_tag_map.cpp9
-rw-r--r--logd/LogStatistics.h21
2 files changed, 14 insertions, 16 deletions
diff --git a/liblog/event_tag_map.cpp b/liblog/event_tag_map.cpp
index 83064fde3..2e2bf8734 100644
--- a/liblog/event_tag_map.cpp
+++ b/liblog/event_tag_map.cpp
@@ -25,9 +25,9 @@
25#include <string.h> 25#include <string.h>
26#include <sys/mman.h> 26#include <sys/mman.h>
27 27
28#include <experimental/string_view>
29#include <functional> 28#include <functional>
30#include <string> 29#include <string>
30#include <string_view>
31#include <unordered_map> 31#include <unordered_map>
32 32
33#include <log/event_tag_map.h> 33#include <log/event_tag_map.h>
@@ -44,10 +44,10 @@
44class MapString { 44class MapString {
45 private: 45 private:
46 const std::string* alloc; // HAS-AN 46 const std::string* alloc; // HAS-AN
47 const std::experimental::string_view str; // HAS-A 47 const std::string_view str; // HAS-A
48 48
49 public: 49 public:
50 operator const std::experimental::string_view() const { 50 operator const std::string_view() const {
51 return str; 51 return str;
52 } 52 }
53 53
@@ -92,8 +92,7 @@ struct std::hash<MapString>
92 : public std::unary_function<const MapString&, size_t> { 92 : public std::unary_function<const MapString&, size_t> {
93 size_t operator()(const MapString& __t) const noexcept { 93 size_t operator()(const MapString& __t) const noexcept {
94 if (!__t.length()) return 0; 94 if (!__t.length()) return 0;
95 return std::hash<std::experimental::string_view>()( 95 return std::hash<std::string_view>()(std::string_view(__t));
96 std::experimental::string_view(__t));
97 } 96 }
98}; 97};
99 98
diff --git a/logd/LogStatistics.h b/logd/LogStatistics.h
index 8808aac70..ac3cf9af2 100644
--- a/logd/LogStatistics.h
+++ b/logd/LogStatistics.h
@@ -25,9 +25,9 @@
25#include <sys/types.h> 25#include <sys/types.h>
26 26
27#include <algorithm> // std::max 27#include <algorithm> // std::max
28#include <experimental/string_view>
29#include <memory> 28#include <memory>
30#include <string> // std::string 29#include <string>
30#include <string_view>
31#include <unordered_map> 31#include <unordered_map>
32 32
33#include <android-base/stringprintf.h> 33#include <android-base/stringprintf.h>
@@ -495,7 +495,7 @@ struct TagEntry : public EntryBaseDropped {
495 495
496struct TagNameKey { 496struct TagNameKey {
497 std::string* alloc; 497 std::string* alloc;
498 std::experimental::string_view name; // Saves space if const char* 498 std::string_view name; // Saves space if const char*
499 499
500 explicit TagNameKey(const LogBufferElement* element) 500 explicit TagNameKey(const LogBufferElement* element)
501 : alloc(nullptr), name("", strlen("")) { 501 : alloc(nullptr), name("", strlen("")) {
@@ -504,31 +504,31 @@ struct TagNameKey {
504 if (tag) { 504 if (tag) {
505 const char* cp = android::tagToName(tag); 505 const char* cp = android::tagToName(tag);
506 if (cp) { 506 if (cp) {
507 name = std::experimental::string_view(cp, strlen(cp)); 507 name = std::string_view(cp, strlen(cp));
508 return; 508 return;
509 } 509 }
510 } 510 }
511 alloc = new std::string( 511 alloc = new std::string(
512 android::base::StringPrintf("[%" PRIu32 "]", tag)); 512 android::base::StringPrintf("[%" PRIu32 "]", tag));
513 if (!alloc) return; 513 if (!alloc) return;
514 name = std::experimental::string_view(alloc->c_str(), alloc->size()); 514 name = std::string_view(alloc->c_str(), alloc->size());
515 return; 515 return;
516 } 516 }
517 const char* msg = element->getMsg(); 517 const char* msg = element->getMsg();
518 if (!msg) { 518 if (!msg) {
519 name = std::experimental::string_view("chatty", strlen("chatty")); 519 name = std::string_view("chatty", strlen("chatty"));
520 return; 520 return;
521 } 521 }
522 ++msg; 522 ++msg;
523 unsigned short len = element->getMsgLen(); 523 unsigned short len = element->getMsgLen();
524 len = (len <= 1) ? 0 : strnlen(msg, len - 1); 524 len = (len <= 1) ? 0 : strnlen(msg, len - 1);
525 if (!len) { 525 if (!len) {
526 name = std::experimental::string_view("<NULL>", strlen("<NULL>")); 526 name = std::string_view("<NULL>", strlen("<NULL>"));
527 return; 527 return;
528 } 528 }
529 alloc = new std::string(msg, len); 529 alloc = new std::string(msg, len);
530 if (!alloc) return; 530 if (!alloc) return;
531 name = std::experimental::string_view(alloc->c_str(), alloc->size()); 531 name = std::string_view(alloc->c_str(), alloc->size());
532 } 532 }
533 533
534 explicit TagNameKey(TagNameKey&& rval) 534 explicit TagNameKey(TagNameKey&& rval)
@@ -545,7 +545,7 @@ struct TagNameKey {
545 if (alloc) delete alloc; 545 if (alloc) delete alloc;
546 } 546 }
547 547
548 operator const std::experimental::string_view() const { 548 operator const std::string_view() const {
549 return name; 549 return name;
550 } 550 }
551 551
@@ -576,8 +576,7 @@ struct std::hash<TagNameKey>
576 : public std::unary_function<const TagNameKey&, size_t> { 576 : public std::unary_function<const TagNameKey&, size_t> {
577 size_t operator()(const TagNameKey& __t) const noexcept { 577 size_t operator()(const TagNameKey& __t) const noexcept {
578 if (!__t.length()) return 0; 578 if (!__t.length()) return 0;
579 return std::hash<std::experimental::string_view>()( 579 return std::hash<std::string_view>()(std::string_view(__t));
580 std::experimental::string_view(__t));
581 } 580 }
582}; 581};
583 582