Skip to content

Commit ca2f0ff

Browse files
timsaucerclaude
andcommitted
refactor(codec): drop redundant buf.is_empty() guards
`<[u8]>::starts_with` on an empty buffer with a non-empty prefix already returns false, so the `buf.is_empty() || !buf.starts_with(MAGIC)` guard in each `try_decode_python_*_udf` function reduces to just `!buf.starts_with(MAGIC)`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent ddd76f8 commit ca2f0ff

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

crates/core/src/codec.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ pub(crate) fn try_encode_python_scalar_udf(node: &ScalarUDF, buf: &mut Vec<u8>)
446446
/// caller to delegate to its `inner` codec (and eventually the
447447
/// `FunctionRegistry`).
448448
pub(crate) fn try_decode_python_scalar_udf(buf: &[u8]) -> Result<Option<Arc<ScalarUDF>>> {
449-
if buf.is_empty() || !buf.starts_with(PY_SCALAR_UDF_MAGIC) {
449+
if !buf.starts_with(PY_SCALAR_UDF_MAGIC) {
450450
return Ok(None);
451451
}
452452
let payload = &buf[PY_SCALAR_UDF_MAGIC.len()..];
@@ -643,7 +643,7 @@ pub(crate) fn try_encode_python_window_udf(node: &WindowUDF, buf: &mut Vec<u8>)
643643
}
644644

645645
pub(crate) fn try_decode_python_window_udf(buf: &[u8]) -> Result<Option<Arc<WindowUDF>>> {
646-
if buf.is_empty() || !buf.starts_with(PY_WINDOW_UDF_MAGIC) {
646+
if !buf.starts_with(PY_WINDOW_UDF_MAGIC) {
647647
return Ok(None);
648648
}
649649
let payload = &buf[PY_WINDOW_UDF_MAGIC.len()..];
@@ -771,7 +771,7 @@ pub(crate) fn try_encode_python_agg_udf(node: &AggregateUDF, buf: &mut Vec<u8>)
771771
}
772772

773773
pub(crate) fn try_decode_python_agg_udf(buf: &[u8]) -> Result<Option<Arc<AggregateUDF>>> {
774-
if buf.is_empty() || !buf.starts_with(PY_AGG_UDF_MAGIC) {
774+
if !buf.starts_with(PY_AGG_UDF_MAGIC) {
775775
return Ok(None);
776776
}
777777
let payload = &buf[PY_AGG_UDF_MAGIC.len()..];

0 commit comments

Comments
 (0)