[#103241] [Ruby master Bug#17777] 2.6.7 fails to build on macOS: implicit declaration of function 'rb_native_mutex_destroy' is invalid in C99 — eregontp@...
Issue #17777 has been reported by Eregon (Benoit Daloze).
17 messages
2021/04/05
[#103305] [Ruby master Feature#17785] Allow named parameters to be keywords — marcandre-ruby-core@...
Issue #17785 has been reported by marcandre (Marc-Andre Lafortune).
21 messages
2021/04/08
[#103342] [Ruby master Feature#17790] Have a way to clear a String without resetting its capacity — jean.boussier@...
Issue #17790 has been reported by byroot (Jean Boussier).
14 messages
2021/04/09
[#103388] [ANN] Multi-factor Authentication of bugs.ruby-lang.org — SHIBATA Hiroshi <hsbt@...>
Hello,
5 messages
2021/04/12
[#103414] Re: [ANN] Multi-factor Authentication of bugs.ruby-lang.org
— Martin J. Dürst <duerst@...>
2021/04/13
Is there a way to use this multi-factor authentication for (like me)
[#103547] List of CI sites to check — Martin J. Dürst <duerst@...>
Hello everybody,
4 messages
2021/04/22
[#103596] [Ruby master Feature#17830] Add Integer#previous and Integer#prev — rafasoaresms@...
Issue #17830 has been reported by rafasoares (Rafael Soares).
9 messages
2021/04/26
[ruby-core:103546] [Ruby master Feature#17790] Have a way to clear a String without resetting its capacity
From:
dsisnero@...
Date:
2021-04-21 23:27:52 UTC
List:
ruby-core #103546
Issue #17790 has been updated by dsisnero (Dominic Sisneros).
That was what I was hoping the addition of memoryview would help with but the only way to interact with the memoryview in ruby is with Fiddle
If we had a ByteArray class that implemented memoryview
buffer = ByteArray.new('this is a string'.bytes)
mv = Fiddle::MemoryView.new(buffer)
mv.byte_size # 16
first8 = mv[0:8] # once Fiddle::MemoryView allows you to slice
socket.write(first8) # once socket.write allows you to write memoryview objects without changing into string.
What memoryview is supposed to do is allow the reading and writing with zero copy because it knows the offsets, strides, etc of the underlying obj in the buffer
So, I think we should instead finish the parts of memoryview that are missing:
1) IO support for memoryview (read into a memoryview object and write from a memoryview object without converting to strings)
2) Add classes that implement the memoryview protocol
3) change String.bytes to return a new ByteArray class that implements the memoryview protocol
4) add a ruby extension that allows you to use memory view objects in ruby (not just Fiddle)
mv = MemoryView.new(obj)
mv[offset:offset_size] #slicing memory views
mv.cast(format, shape) - change format or shape of memoryview but keep data
mv.format
mv.strides
mv.shape
----------------------------------------
Feature #17790: Have a way to clear a String without resetting its capacity
https://bugs.ruby-lang.org/issues/17790#change-91647
* Author: byroot (Jean Boussier)
* Status: Open
* Priority: Normal
----------------------------------------
In some tight loop it can be useful to re-use a buffer string. For instance:
```ruby
buffer = String.new(encoding: Encoding::BINARY, capacity: 1024)
10.times do
build_next_packet(buffer)
udp_socket.send(buffer)
buffer.clear
end
```
Currently `Array#clear` preserve the Array capacity, but `String#clear` doesn't:
```ruby
>> puts ObjectSpace.dump(Array.new(20).clear)
{"address":"0x7fd3260a1558", "type":"ARRAY", "class":"0x7fd3230972e0", "length":0, "memsize":200, "flags":{"wb_protected":true}}
>> puts ObjectSpace.dump(String.new(encoding: Encoding::BINARY, capacity: 1024).clear)
{"address":"0x7fd322a8a320", "type":"STRING", "class":"0x7fd3230b75b8", "embedded":true, "bytesize":0, "value":"", "memsize":40, "flags":{"wb_protected":true}}
```
It would be useful if `String#clear` wouldn't free allocated memory, but if it's a backward compatibility concern to change it, then maybe another method could make sense?
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>