Skip to content

Commit 2eaeb0a

Browse files
committed
Merge remote-tracking branch 'neheb/as'
2 parents 8bb452a + 1f22735 commit 2eaeb0a

14 files changed

Lines changed: 27 additions & 28 deletions

ebml/EbmlDate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class EBML_DLL_API EbmlDate : public EbmlElementDefaultSameStorage<std::int64_t>
2222
{
2323
if (classInfo.HasDefault())
2424
{
25-
auto def = static_cast<const EbmlCallbacksWithDefault<std::int64_t> &>(classInfo);
25+
const auto& def = static_cast<const EbmlCallbacksWithDefault<std::int64_t> &>(classInfo);
2626
SetValue(def.DefaultValue());
2727
}
2828
}

ebml/EbmlElement.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ static inline EbmlElement & tEBML_SEM_CREATE(const EbmlSemantic & s)
430430
return s.Create();
431431
}
432432

433-
using _GetSemanticContext = const class EbmlSemanticContext &(*)();
433+
using _GetSemanticContext = const EbmlSemanticContext &(*)();
434434

435435
/*!
436436
Context of the element
@@ -650,7 +650,7 @@ class EBML_DLL_API EbmlElement {
650650

651651
private:
652652
std::size_t HeadSize() const {
653-
return EBML_ID_LENGTH((const EbmlId&)*this) + CodedSizeLength(Size, SizeLength, bSizeIsFinite);
653+
return EBML_ID_LENGTH(static_cast<const EbmlId&>(*this)) + CodedSizeLength(Size, SizeLength, bSizeIsFinite);
654654
} /// return the size of the head, on reading/writing
655655

656656
std::uint64_t Size; ///< the size of the data to write

src/EbmlElement.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -195,23 +195,22 @@ EbmlElement * EbmlElement::FindNextID(IOCallback & DataStream, const EbmlCallbac
195195
} while (_SizeLength == 0);
196196
}
197197

198-
const auto PossibleID = EbmlId(EbmlId::FromBuffer(PossibleId.data(), PossibleID_Length));
199-
auto Result = [=] {
200-
if (PossibleID != EBML_INFO_ID(ClassInfos))
201-
{
198+
auto Result = [&]() -> EbmlElement * {
199+
auto pID = EbmlId(EbmlId::FromBuffer(PossibleId.data(), PossibleID_Length));
200+
if (pID != EBML_INFO_ID(ClassInfos)) {
202201
if (SizeFound == SizeUnknown)
203-
return static_cast<EbmlElement *>(nullptr);
204-
return static_cast<EbmlElement *>(new EbmlDummy(PossibleID));
202+
return nullptr;
203+
return new EbmlDummy(pID);
205204
}
206205
if (SizeFound != SizeUnknown && MaxDataSize < SizeFound)
207-
return static_cast<EbmlElement *>(nullptr);
206+
return nullptr;
208207
// check if the size is not all 1s
209208
if (SizeFound == SizeUnknown && !ClassInfos.CanHaveInfiniteSize())
210-
return static_cast<EbmlElement *>(nullptr);
209+
return nullptr;
211210
return &EBML_INFO_CREATE(ClassInfos);
212211
}();
213212

214-
if (Result == nullptr)
213+
if (!Result)
215214
return nullptr;
216215

217216
if (!Result->SizeIsValid(SizeFound)) {
@@ -454,7 +453,7 @@ EbmlElement *EbmlElement::CreateElementUsingContext(const EbmlId & aID, const Eb
454453

455454
// parent elements
456455
if (EBML_CTX_MASTER(Context) != nullptr && aID == EBML_INFO_ID(*EBML_CTX_MASTER(Context))) {
457-
auto Callbacks = *EBML_CTX_MASTER(Context);
456+
const auto& Callbacks = *EBML_CTX_MASTER(Context);
458457
if (AsInfiniteSize && !Callbacks.CanHaveInfiniteSize())
459458
return nullptr;
460459
LowLevel++; // already one level up (same as context)
@@ -518,7 +517,7 @@ filepos_t EbmlElement::MakeRenderHead(IOCallback & output, bool bKeepPosition)
518517
std::array<binary, 4 + 8> FinalHead; // Class D + 64 bits coded size
519518
std::size_t FinalHeadSize;
520519

521-
FinalHeadSize = EBML_ID_LENGTH((const EbmlId&)*this);
520+
FinalHeadSize = EBML_ID_LENGTH(static_cast<const EbmlId&>(*this));
522521
EbmlId(*this).Fill(FinalHead.data());
523522

524523
const unsigned int CodedSize = CodedSizeLength(Size, SizeLength, bSizeIsFinite);

src/EbmlFloat.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ EbmlFloat::EbmlFloat(const EbmlCallbacksDefault<double> & classInfo, const EbmlF
1919
SetPrecision(prec);
2020
if (classInfo.HasDefault())
2121
{
22-
auto def = static_cast<const EbmlCallbacksWithDefault<double> &>(classInfo);
22+
const auto& def = static_cast<const EbmlCallbacksWithDefault<double> &>(classInfo);
2323
SetValue(def.DefaultValue());
2424
}
2525
}

src/EbmlMaster.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ std::uint64_t EbmlMaster::UpdateSize(const ShouldWrite & writeFilter, bool bForc
104104
SetSize_(0);
105105

106106
if (!IsFiniteSize())
107-
return (0-1);
107+
return std::numeric_limits<std::uint64_t>::max();
108108

109109
if (!bForceRender) {
110110
assert(CheckMandatory());
@@ -117,7 +117,7 @@ std::uint64_t EbmlMaster::UpdateSize(const ShouldWrite & writeFilter, bool bForc
117117
const std::uint64_t SizeToAdd = Element->ElementSize(writeFilter);
118118
#if !defined(NDEBUG)
119119
if (static_cast<std::int64_t>(SizeToAdd) == (0-1))
120-
return (0-1);
120+
return std::numeric_limits<std::uint64_t>::max();
121121
#endif // !NDEBUG
122122
SetSize_(GetSize() + SizeToAdd);
123123
}

src/EbmlSInteger.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ EbmlSInteger::EbmlSInteger(const EbmlCallbacksDefault<std::int64_t> & classInfo)
3434
{
3535
if (classInfo.HasDefault())
3636
{
37-
auto def = static_cast<const EbmlCallbacksWithDefault<std::int64_t> &>(classInfo);
37+
const auto& def = static_cast<const EbmlCallbacksWithDefault<std::int64_t> &>(classInfo);
3838
SetValue(def.DefaultValue());
3939
}
4040
}

src/EbmlString.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ EbmlString::EbmlString(const EbmlCallbacksDefault<const char *> & classInfo)
1515
{
1616
if (classInfo.HasDefault())
1717
{
18-
auto def = static_cast<const EbmlCallbacksWithDefault<const char *> &>(classInfo);
18+
const auto& def = static_cast<const EbmlCallbacksWithDefault<const char *> &>(classInfo);
1919
SetValue(def.DefaultValue());
2020
}
2121
}

src/EbmlUInteger.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ EbmlUInteger::EbmlUInteger(const EbmlCallbacksDefault<std::uint64_t> & classInfo
1717
{
1818
if (classInfo.HasDefault())
1919
{
20-
auto def = static_cast<const EbmlCallbacksWithDefault<std::uint64_t> &>(classInfo);
20+
const auto& def = static_cast<const EbmlCallbacksWithDefault<std::uint64_t> &>(classInfo);
2121
SetValue(def.DefaultValue());
2222
}
2323
}

src/EbmlUnicodeString.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ EbmlUnicodeString::EbmlUnicodeString(const EbmlCallbacksDefault<const wchar_t *>
104104
{
105105
if (classInfo.HasDefault())
106106
{
107-
auto def = static_cast<const EbmlCallbacksWithDefault<const wchar_t *> &>(classInfo);
107+
const auto& def = static_cast<const EbmlCallbacksWithDefault<const wchar_t *> &>(classInfo);
108108
SetValue(UTFstring{def.DefaultValue()});
109109
}
110110
}

src/MemIOCallback.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ std::size_t MemIOCallback::write(IOCallback & IOToRead, std::size_t Size)
9191
}
9292
IOToRead.readFully(&dataBuffer[dataBufferPos], Size);
9393
dataBufferTotalSize = Size;
94-
return Size;
94+
return static_cast<std::uint32_t>(Size);
9595
}
9696

9797
} // namespace libebml

0 commit comments

Comments
 (0)