Commit c08609d5 authored by Nils Fenner's avatar Nils Fenner

fix const-correctness on AnyPointer equality checks

parent 06a71367
...@@ -79,7 +79,7 @@ kj::Own<ClientHook> AnyPointer::Pipeline::asCap() { ...@@ -79,7 +79,7 @@ kj::Own<ClientHook> AnyPointer::Pipeline::asCap() {
#endif // !CAPNP_LITE #endif // !CAPNP_LITE
Equality AnyStruct::Reader::equals(AnyStruct::Reader right) { Equality AnyStruct::Reader::equals(AnyStruct::Reader right) const {
auto dataL = getDataSection(); auto dataL = getDataSection();
size_t dataSizeL = dataL.size(); size_t dataSizeL = dataL.size();
while(dataSizeL > 0 && dataL[dataSizeL - 1] == 0) { while(dataSizeL > 0 && dataL[dataSizeL - 1] == 0) {
...@@ -150,7 +150,7 @@ kj::StringPtr KJ_STRINGIFY(Equality res) { ...@@ -150,7 +150,7 @@ kj::StringPtr KJ_STRINGIFY(Equality res) {
KJ_UNREACHABLE; KJ_UNREACHABLE;
} }
Equality AnyList::Reader::equals(AnyList::Reader right) { Equality AnyList::Reader::equals(AnyList::Reader right) const {
if(size() != right.size()) { if(size() != right.size()) {
return Equality::NOT_EQUAL; return Equality::NOT_EQUAL;
} }
...@@ -209,7 +209,7 @@ Equality AnyList::Reader::equals(AnyList::Reader right) { ...@@ -209,7 +209,7 @@ Equality AnyList::Reader::equals(AnyList::Reader right) {
KJ_UNREACHABLE; KJ_UNREACHABLE;
} }
Equality AnyPointer::Reader::equals(AnyPointer::Reader right) { Equality AnyPointer::Reader::equals(AnyPointer::Reader right) const {
if(getPointerType() != right.getPointerType()) { if(getPointerType() != right.getPointerType()) {
return Equality::NOT_EQUAL; return Equality::NOT_EQUAL;
} }
...@@ -227,7 +227,7 @@ Equality AnyPointer::Reader::equals(AnyPointer::Reader right) { ...@@ -227,7 +227,7 @@ Equality AnyPointer::Reader::equals(AnyPointer::Reader right) {
KJ_UNREACHABLE; KJ_UNREACHABLE;
} }
bool AnyPointer::Reader::operator==(AnyPointer::Reader right) { bool AnyPointer::Reader::operator==(AnyPointer::Reader right) const {
switch(equals(right)) { switch(equals(right)) {
case Equality::EQUAL: case Equality::EQUAL:
return true; return true;
...@@ -240,7 +240,7 @@ bool AnyPointer::Reader::operator==(AnyPointer::Reader right) { ...@@ -240,7 +240,7 @@ bool AnyPointer::Reader::operator==(AnyPointer::Reader right) {
KJ_UNREACHABLE; KJ_UNREACHABLE;
} }
bool AnyStruct::Reader::operator==(AnyStruct::Reader right) { bool AnyStruct::Reader::operator==(AnyStruct::Reader right) const {
switch(equals(right)) { switch(equals(right)) {
case Equality::EQUAL: case Equality::EQUAL:
return true; return true;
...@@ -253,7 +253,7 @@ bool AnyStruct::Reader::operator==(AnyStruct::Reader right) { ...@@ -253,7 +253,7 @@ bool AnyStruct::Reader::operator==(AnyStruct::Reader right) {
KJ_UNREACHABLE; KJ_UNREACHABLE;
} }
bool AnyList::Reader::operator==(AnyList::Reader right) { bool AnyList::Reader::operator==(AnyList::Reader right) const {
switch(equals(right)) { switch(equals(right)) {
case Equality::EQUAL: case Equality::EQUAL:
return true; return true;
......
...@@ -104,9 +104,9 @@ struct AnyPointer { ...@@ -104,9 +104,9 @@ struct AnyPointer {
inline bool isList() const { return getPointerType() == PointerType::LIST; } inline bool isList() const { return getPointerType() == PointerType::LIST; }
inline bool isCapability() const { return getPointerType() == PointerType::CAPABILITY; } inline bool isCapability() const { return getPointerType() == PointerType::CAPABILITY; }
Equality equals(AnyPointer::Reader right); Equality equals(AnyPointer::Reader right) const;
bool operator==(AnyPointer::Reader right); bool operator==(AnyPointer::Reader right) const;
inline bool operator!=(AnyPointer::Reader right) { inline bool operator!=(AnyPointer::Reader right) const {
return !(*this == right); return !(*this == right);
} }
...@@ -158,13 +158,13 @@ struct AnyPointer { ...@@ -158,13 +158,13 @@ struct AnyPointer {
inline bool isList() { return getPointerType() == PointerType::LIST; } inline bool isList() { return getPointerType() == PointerType::LIST; }
inline bool isCapability() { return getPointerType() == PointerType::CAPABILITY; } inline bool isCapability() { return getPointerType() == PointerType::CAPABILITY; }
inline Equality equals(AnyPointer::Reader right) { inline Equality equals(AnyPointer::Reader right) const {
return asReader().equals(right); return asReader().equals(right);
} }
inline bool operator==(AnyPointer::Reader right) { inline bool operator==(AnyPointer::Reader right) const {
return asReader() == right; return asReader() == right;
} }
inline bool operator!=(AnyPointer::Reader right) { inline bool operator!=(AnyPointer::Reader right) const {
return !(*this == right); return !(*this == right);
} }
...@@ -477,9 +477,9 @@ public: ...@@ -477,9 +477,9 @@ public:
return _reader.canonicalize(); return _reader.canonicalize();
} }
Equality equals(AnyStruct::Reader right); Equality equals(AnyStruct::Reader right) const;
bool operator==(AnyStruct::Reader right); bool operator==(AnyStruct::Reader right) const;
inline bool operator!=(AnyStruct::Reader right) { inline bool operator!=(AnyStruct::Reader right) const {
return !(*this == right); return !(*this == right);
} }
...@@ -521,13 +521,13 @@ public: ...@@ -521,13 +521,13 @@ public:
return List<AnyPointer>::Builder(_builder.getPointerSectionAsList()); return List<AnyPointer>::Builder(_builder.getPointerSectionAsList());
} }
inline Equality equals(AnyStruct::Reader right) { inline Equality equals(AnyStruct::Reader right) const {
return asReader().equals(right); return asReader().equals(right);
} }
inline bool operator==(AnyStruct::Reader right) { inline bool operator==(AnyStruct::Reader right) const {
return asReader() == right; return asReader() == right;
} }
inline bool operator!=(AnyStruct::Reader right) { inline bool operator!=(AnyStruct::Reader right) const {
return !(*this == right); return !(*this == right);
} }
...@@ -651,9 +651,9 @@ public: ...@@ -651,9 +651,9 @@ public:
inline kj::ArrayPtr<const byte> getRawBytes() { return _reader.asRawBytes(); } inline kj::ArrayPtr<const byte> getRawBytes() { return _reader.asRawBytes(); }
Equality equals(AnyList::Reader right); Equality equals(AnyList::Reader right) const;
bool operator==(AnyList::Reader right); bool operator==(AnyList::Reader right) const;
inline bool operator!=(AnyList::Reader right) { inline bool operator!=(AnyList::Reader right) const {
return !(*this == right); return !(*this == right);
} }
...@@ -689,11 +689,11 @@ public: ...@@ -689,11 +689,11 @@ public:
inline ElementSize getElementSize() { return _builder.getElementSize(); } inline ElementSize getElementSize() { return _builder.getElementSize(); }
inline uint size() { return unbound(_builder.size() / ELEMENTS); } inline uint size() { return unbound(_builder.size() / ELEMENTS); }
Equality equals(AnyList::Reader right); Equality equals(AnyList::Reader right) const;
inline bool operator==(AnyList::Reader right) { inline bool operator==(AnyList::Reader right) const{
return asReader() == right; return asReader() == right;
} }
inline bool operator!=(AnyList::Reader right) { inline bool operator!=(AnyList::Reader right) const{
return !(*this == right); return !(*this == right);
} }
......
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