Question about Linker.Option.isTrivial()

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Mon Jan 15 15:57:36 UTC 2024


On 15/01/2024 15:23, 刘希晨 wrote:
> For example, in 
> https://www.postgresql.org/docs/current/protocol-message-formats.html 
> <https://urldefense.com/v3/__https://www.postgresql.org/docs/current/protocol-message-formats.html__;!!ACWV5N9M2RV99hQ!MyEp6roAVJiCW7ICOb0qsj7sTbl0-6FMpSP_cUorkgFXlpYaIVusJQFoY7eOtiEupFUi3lUU5xivRt9F_QCYn96J52eW$>, 
> the postgresql startup message contains a length prefix indicates the 
> total length, while within the message body, multiple string were 
> represented as key-value pair, so we need to call 
> MemorySegment.getString() multiple times to retrieve them, and we must 
> care about the offset value here.
>
> Thus I think it's quite useful to have a getStringBytes() API in 
> memorySegment, it would be needed and constantly used.

Thanks for the pointer. It is indeed a case of "back to back" strings.

One possible workaround, with current API, is to simply get the string 
first, then get the string bytes (and that would be your "next offset").

Another thing you probably need in this mode is some kind of start 
offset as well (otherwise you need to slice). So perhaps the 
getStringBytes() could be a lower-level method which takes a start offset.

Maurizio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/panama-dev/attachments/20240115/8f24ced2/attachment.htm>


More information about the panama-dev mailing list