chaokunyang commented on code in PR #2585:
URL: https://github.com/apache/fory/pull/2585#discussion_r2341212553
##########
rust/fory-core/src/serializer/string.rs:
##########
@@ -15,27 +15,60 @@
// specific language governing permissions and limitations
// under the License.
+use crate::buffer::Writer;
use crate::error::Error;
use crate::fory::Fory;
+use crate::meta::is_latin;
use crate::resolver::context::ReadContext;
use crate::resolver::context::WriteContext;
use crate::serializer::Serializer;
use crate::types::{ForyGeneralList, TypeId};
use std::mem;
+enum StrEncoding {
+ Latin1 = 0,
+ Utf16 = 1,
+ Utf8 = 2,
+}
+
impl Serializer for String {
fn reserved_space() -> usize {
mem::size_of::<i32>()
}
fn write(&self, context: &mut WriteContext) {
- context.writer.var_int32(self.len() as i32);
- context.writer.bytes(self.as_bytes());
+ let mut buf = Writer::default();
+ let len;
+ let bitor;
+ if is_latin(self.as_str()) {
Review Comment:
Maybe not in this PR, we could implement a get_latin1_length, which return
-1 if not latin1. And then write length and encoding first, then we can just
write string byte by byte directly into the writer
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]