This is an automated email from the ASF dual-hosted git repository.
chaokunyang pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/fory.git
The following commit(s) were added to refs/heads/main by this push:
new 14097b53e chore(rust): remove tag read/write (#2681)
14097b53e is described below
commit 14097b53e9251be270871a28214135e165f3a1c9
Author: Shawn Yang <[email protected]>
AuthorDate: Mon Sep 29 11:38:34 2025 +0800
chore(rust): remove tag read/write (#2681)
<!--
**Thanks for contributing to Apache Fory™.**
**If this is your first time opening a PR on fory, you can refer to
[CONTRIBUTING.md](https://github.com/apache/fory/blob/main/CONTRIBUTING.md).**
Contribution Checklist
- The **Apache Fory™** community has requirements on the naming of pr
titles. You can also find instructions in
[CONTRIBUTING.md](https://github.com/apache/fory/blob/main/CONTRIBUTING.md).
- Apache Fory™ has a strong focus on performance. If the PR you submit
will have an impact on performance, please benchmark it first and
provide the benchmark result here.
-->
## Why?
<!-- Describe the purpose of this PR. -->
## What does this PR do?
<!-- Describe the details of this PR. -->
## Related issues
<!--
Is there any related issue? If this PR closes them you say say
fix/closes:
- #xxxx0
- #xxxx1
- Fixes #xxxx2
-->
## Does this PR introduce any user-facing change?
<!--
If any user-facing interface changes, please [open an
issue](https://github.com/apache/fory/issues/new/choose) describing the
need to do so and update the document if necessary.
Delete section if not applicable.
-->
- [ ] Does this PR introduce any public API change?
- [ ] Does this PR introduce any binary protocol compatibility change?
## Benchmark
<!--
When the PR has an impact on performance (if you don't know whether the
PR will have an impact on performance, you can submit the PR first, and
if it will have impact on performance, the code reviewer will explain
it), be sure to attach a benchmark data here.
Delete section if not applicable.
-->
---
rust/fory-core/src/resolver/context.rs | 43 ----------------------------------
1 file changed, 43 deletions(-)
diff --git a/rust/fory-core/src/resolver/context.rs
b/rust/fory-core/src/resolver/context.rs
index eca165b35..bf93c48e1 100644
--- a/rust/fory-core/src/resolver/context.rs
+++ b/rust/fory-core/src/resolver/context.rs
@@ -16,9 +16,7 @@
// under the License.
use crate::buffer::{Reader, Writer};
-use crate::error::Error;
use crate::fory::Fory;
-use anyhow::anyhow;
use crate::meta::TypeMeta;
use crate::resolver::meta_resolver::{MetaReaderResolver, MetaWriterResolver};
@@ -27,7 +25,6 @@ use std::rc::Rc;
pub struct WriteContext<'se> {
pub writer: &'se mut Writer,
- pub tags: Vec<&'static str>,
fory: &'se Fory,
meta_resolver: MetaWriterResolver<'se>,
pub ref_writer: RefWriter,
@@ -37,7 +34,6 @@ impl<'se> WriteContext<'se> {
pub fn new(fory: &'se Fory, writer: &'se mut Writer) -> WriteContext<'se> {
WriteContext {
writer,
- tags: Vec::new(),
fory,
meta_resolver: MetaWriterResolver::default(),
ref_writer: RefWriter::new(),
@@ -63,30 +59,10 @@ impl<'se> WriteContext<'se> {
pub fn get_fory(&self) -> &Fory {
self.fory
}
-
- pub fn write_tag(&mut self, tag: &'static str) {
- const USESTRINGVALUE: u8 = 0;
- const USESTRINGID: u8 = 1;
-
- let mayby_idx = self.tags.iter().position(|x| *x == tag);
- match mayby_idx {
- Some(idx) => {
- self.writer.u8(USESTRINGID);
- self.writer.i16(idx as i16);
- }
- None => {
- self.writer.u8(USESTRINGVALUE);
- self.writer.skip(8); // todo tag hash
- self.writer.i16(tag.len() as i16);
- self.writer.bytes(tag.as_bytes());
- }
- };
- }
}
pub struct ReadContext<'de, 'bf: 'de> {
pub reader: Reader<'bf>,
- pub tags: Vec<&'de str>,
fory: &'de Fory,
pub meta_resolver: MetaReaderResolver,
pub ref_reader: RefReader,
@@ -96,7 +72,6 @@ impl<'de, 'bf: 'de> ReadContext<'de, 'bf> {
pub fn new(fory: &'de Fory, reader: Reader<'bf>) -> ReadContext<'de, 'bf> {
ReadContext {
reader,
- tags: Vec::new(),
fory,
meta_resolver: MetaReaderResolver::default(),
ref_reader: RefReader::new(),
@@ -116,22 +91,4 @@ impl<'de, 'bf: 'de> ReadContext<'de, 'bf> {
&self.reader.slice_after_cursor()[offset..],
))
}
-
- pub fn read_tag(&mut self) -> Result<&str, Error> {
- const USESTRINGVALUE: u8 = 0;
- const USESTRINGID: u8 = 1;
- let tag_type = self.reader.u8();
- if tag_type == USESTRINGID {
- Ok(self.tags[self.reader.i16() as usize])
- } else if tag_type == USESTRINGVALUE {
- self.reader.skip(8); // todo tag hash
- let len = self.reader.i16();
- let tag: &str =
- unsafe { std::str::from_utf8_unchecked(self.reader.bytes(len
as usize)) };
- self.tags.push(tag);
- Ok(tag)
- } else {
- Err(anyhow!("Unknown tag type, value:{tag_type}"))?
- }
- }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]