From c9b236e5cafaea9d09ff8102140c72eb3d70e302 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 21 Jun 2019 14:14:58 +0000 Subject: compiler: open code string slice expressions Currently a string slice expression is implemented with a runtime call __go_string_slice. Change it to open code it, which is more efficient, and allows the backend to further optimize it. Also omit the write barrier for length-only update (i.e. s = s[:n]). Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/182540 From-SVN: r272549 --- gcc/go/gofrontend/expressions.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'gcc/go/gofrontend/expressions.h') diff --git a/gcc/go/gofrontend/expressions.h b/gcc/go/gofrontend/expressions.h index 38dee04..2c505a9 100644 --- a/gcc/go/gofrontend/expressions.h +++ b/gcc/go/gofrontend/expressions.h @@ -3133,6 +3133,18 @@ class String_index_expression : public Expression string() const { return this->string_; } + // Return the index of a simple index expression, or the start index + // of a slice expression. + Expression* + start() const + { return this->start_; } + + // Return the end index of a slice expression. This is NULL for a + // simple index expression. + Expression* + end() const + { return this->end_; } + protected: int do_traverse(Traverse*); -- cgit v1.1