From 25d38d918d7efe79056226dc61108911c877bf71 Mon Sep 17 00:00:00 2001 From: Scallop Ye Date: Wed, 17 Apr 2024 17:00:56 +0800 Subject: [PATCH] Simplify `Reader::read_v4_or_reg_name` --- src/parser.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/parser.rs b/src/parser.rs index 8e3b415..6a4ddf5 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -290,12 +290,8 @@ impl<'a> Reader<'a> { } fn read_v4_or_reg_name(&mut self) -> Result { - let v4 = self.read_v4(); - let v4_end = self.pos; - self.read(REG_NAME)?; - - Ok(match v4 { - Some(_addr) if self.pos == v4_end => HostMeta::Ipv4( + Ok(match (self.read_v4(), self.read(REG_NAME)?) { + (Some(_addr), false) => HostMeta::Ipv4( #[cfg(feature = "net")] _addr.into(), ),