From 63958fba58716ed435563321944f7d4663d2ee2d Mon Sep 17 00:00:00 2001 From: Sean Silva Date: Wed, 5 Jun 2013 23:32:27 +0000 Subject: Add BinaryRef binary_size() method. This avoids making assumptions about the data representation. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@183349 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Object/YAML.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include') diff --git a/include/llvm/Object/YAML.h b/include/llvm/Object/YAML.h index e6f1da1..92811b0 100644 --- a/include/llvm/Object/YAML.h +++ b/include/llvm/Object/YAML.h @@ -43,6 +43,13 @@ public: assert(isBinary); return Data; } + /// \brief The number of bytes that are represented by this BinaryRef. + /// This is the number of bytes that writeAsBinary() will write. + ArrayRef::size_type binary_size() const { + if (!isBinary) + return Data.size() / 2; + return Data.size(); + } bool operator==(const BinaryRef &Ref) { // Special case for default constructed BinaryRef. if (Ref.Data.empty() && Data.empty()) -- cgit v1.1