Skip to content

Commit 8bca5c5

Browse files
committed
remove unneeded things
1 parent ce29c19 commit 8bca5c5

1 file changed

Lines changed: 1 addition & 31 deletions

File tree

meta/src/meta/codegen_go.py

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -562,15 +562,7 @@ def _generate_NewMessage(
562562
# option_var is the original Option variable name for checking .Valid
563563
oneof_groups: dict[str, list[tuple[str, str, str]]] = {}
564564

565-
from .target import Builtin, OptionType, Var
566-
567-
def _go_optional_string_unwrap_needs_ptr(field_expr: TargetExpr) -> bool:
568-
"""unwrap_option_or yields a plain string; optional proto fields need *string."""
569-
return (
570-
isinstance(field_expr, Call)
571-
and isinstance(field_expr.func, Builtin)
572-
and field_expr.func.name == "unwrap_option_or"
573-
)
565+
from .target import OptionType, Var
574566

575567
def unwrap_if_option(field_expr, field_value: str) -> tuple[str, str]:
576568
"""Unwrap Option type values for struct field assignment.
@@ -600,13 +592,6 @@ def unwrap_if_option(field_expr, field_value: str) -> tuple[str, str]:
600592
lines.append(f"{indent}}}")
601593
return (field_value, tmp)
602594
else:
603-
# Ptr-wrapped scalar: usually deref for plain struct fields (float64, int64, …).
604-
# Proto `optional string` fields are *string in Go — pass *string through.
605-
inner_go = self.gen_type(field_expr.type.element_type)
606-
if inner_go == "string":
607-
opt_go = self.gen_option_type(inner_go)
608-
if opt_go.startswith("*"):
609-
return (field_value, field_value)
610595
return (field_value, f"deref({field_value}, {zero})")
611596
return (field_value, field_value)
612597

@@ -663,21 +648,6 @@ def unwrap_if_option(field_expr, field_value: str) -> tuple[str, str]:
663648
pascal_field = to_pascal_case(field_name)
664649
_, field_value = unwrap_if_option(field_expr, field_value)
665650

666-
proto_msg = self.proto_messages.get((expr.module, expr.name))
667-
if proto_msg is not None:
668-
pf = next(
669-
(f for f in proto_msg.fields if f.name == field_name),
670-
None,
671-
)
672-
if (
673-
pf is not None
674-
and pf.is_optional
675-
and not pf.is_repeated
676-
and pf.type == "string"
677-
and _go_optional_string_unwrap_needs_ptr(field_expr)
678-
):
679-
field_value = f"ptr({field_value})"
680-
681651
regular_assignments.append(f"{pascal_field}: {field_value}")
682652

683653
# Generate struct literal with regular fields only

0 commit comments

Comments
 (0)