RFR: 8331193: Return references when possible in GrowableArray
Johan Sjölen
jsjolen at openjdk.org
Fri Apr 26 12:34:34 UTC 2024
On Fri, 26 Apr 2024 12:25:46 GMT, Stefan Karlsson <stefank at openjdk.org> wrote:
> There are two `at` functions, with and without const:
>
> ```
> E& at(int i) {
> ...
> E const& at(int i) const {
> ```
>
> This change makes the following functions const, but the return values non-const:
>
> ```
> E& first() const {
> ...
> E& top() const {
> ...
> E& last() const {
> ```
>
> I think there should be some consistency w.r.t. between all these functions.
Yeah, I'm fine with adding the corresponding `const` functions in this PR. According to cppreference it's fine to add on a `const` using `const_cast`, so in this way we avoid copy-pasting function definitions.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/18975#issuecomment-2079297088
More information about the hotspot-dev
mailing list