Skip to content

[NetKAT] Rename PrettyPrint to ToString. #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions netkat/symbolic_packet.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ SymbolicPacket SymbolicPacketManager::NodeToPacket(DecisionNode&& node) {
// expensive.
#ifndef NDEBUG
for (const auto& [value, branch] : node.branch_by_field_value) {
CHECK(branch != node.default_branch) << PrettyPrint(node);
CHECK(branch != node.default_branch) << ToString(node);
if (!IsEmptySet(branch) && !IsFullSet(branch)) {
auto& branch_node = GetNodeOrDie(branch);
CHECK(branch_node.field > node.field) << absl::StreamFormat(
"(%v > %v)\n---branch---\n%s\n---node---\n%s", branch_node.field,
node.field, PrettyPrint(branch), PrettyPrint(node));
node.field, ToString(branch), ToString(node));
}
}
#endif
Expand Down Expand Up @@ -297,7 +297,7 @@ SymbolicPacket SymbolicPacketManager::Xor(SymbolicPacket left,
return Or(And(Not(left), right), And(left, Not(right)));
}

std::string SymbolicPacketManager::PrettyPrint(SymbolicPacket packet) const {
std::string SymbolicPacketManager::ToString(SymbolicPacket packet) const {
std::string result;
std::queue<SymbolicPacket> work_list{{packet}};
absl::flat_hash_set<SymbolicPacket> visited{packet};
Expand Down Expand Up @@ -329,7 +329,7 @@ std::string SymbolicPacketManager::PrettyPrint(SymbolicPacket packet) const {
return result;
}

std::string SymbolicPacketManager::PrettyPrint(const DecisionNode& node) const {
std::string SymbolicPacketManager::ToString(const DecisionNode& node) const {
std::string result;
std::vector<SymbolicPacket> work_list;
std::string field =
Expand All @@ -346,7 +346,7 @@ std::string SymbolicPacketManager::PrettyPrint(const DecisionNode& node) const {
}

for (const SymbolicPacket& branch : work_list) {
absl::StrAppend(&result, PrettyPrint(branch));
absl::StrAppend(&result, ToString(branch));
}

return result;
Expand Down
4 changes: 2 additions & 2 deletions netkat/symbolic_packet.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class SymbolicPacketManager {

// Returns a human-readable string representation of the given `packet`,
// intended for debugging.
[[nodiscard]] std::string PrettyPrint(SymbolicPacket packet) const;
[[nodiscard]] std::string ToString(SymbolicPacket packet) const;

// Dynamically checks all class invariants. Exposed for testing only.
absl::Status CheckInternalInvariants() const;
Expand Down Expand Up @@ -332,7 +332,7 @@ class SymbolicPacketManager {
// is NOT expected to be called with these special packets that crash.
const DecisionNode& GetNodeOrDie(SymbolicPacket packet) const;

[[nodiscard]] std::string PrettyPrint(const DecisionNode& node) const;
[[nodiscard]] std::string ToString(const DecisionNode& node) const;

// The page size of the `nodes_` vector: 64 MiB or ~ 67 MB.
// Chosen large enough to reduce the cost of dynamic allocation, and small
Expand Down
2 changes: 1 addition & 1 deletion netkat/symbolic_packet_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ SymbolicPacketManager& Manager() {
//
// We define this much better override, which GoogleTest gives precedence to.
void PrintTo(const SymbolicPacket& packet, std::ostream* os) {
*os << Manager().PrettyPrint(packet);
*os << Manager().ToString(packet);
}

namespace {
Expand Down