diff --git a/esphome/codegen.py b/esphome/codegen.py index 4ea41ad191..6d55c6023d 100644 --- a/esphome/codegen.py +++ b/esphome/codegen.py @@ -19,7 +19,6 @@ from esphome.cpp_generator import ( # noqa: F401 RawExpression, RawStatement, Statement, - StringRefLiteral, StructInitializer, TemplateArguments, add, diff --git a/esphome/cpp_generator.py b/esphome/cpp_generator.py index 89993d997c..1a47b346b7 100644 --- a/esphome/cpp_generator.py +++ b/esphome/cpp_generator.py @@ -243,23 +243,6 @@ class LogStringLiteral(Literal): return f"LOG_STR({cpp_string_escape(self.string)})" -class StringRefLiteral(Literal): - """A StringRef literal using from_lit() for compile-time string references. - - Uses StringRef::from_lit() which stores pointer + length (8 bytes) instead of - std::string (24-32 bytes + heap allocation). The string data stays in flash. - """ - - __slots__ = ("string",) - - def __init__(self, string: str) -> None: - super().__init__() - self.string = string - - def __str__(self) -> str: - return f"StringRef::from_lit({cpp_string_escape(self.string)})" - - class IntLiteral(Literal): __slots__ = ("i",) diff --git a/tests/unit_tests/test_cpp_generator.py b/tests/unit_tests/test_cpp_generator.py index 428e7626a1..2c9f760c8e 100644 --- a/tests/unit_tests/test_cpp_generator.py +++ b/tests/unit_tests/test_cpp_generator.py @@ -248,12 +248,6 @@ class TestLiterals: (cg.FloatLiteral(4.2), "4.2f"), (cg.FloatLiteral(1.23456789), "1.23456789f"), (cg.FloatLiteral(math.nan), "NAN"), - (cg.StringRefLiteral("foo"), 'StringRef::from_lit("foo")'), - (cg.StringRefLiteral(""), 'StringRef::from_lit("")'), - ( - cg.StringRefLiteral('with "quotes"'), - 'StringRef::from_lit("with \\042quotes\\042")', - ), ), ) def test_str__simple(self, target: cg.Literal, expected: str):