-
Notifications
You must be signed in to change notification settings - Fork 29
Optimize table-like length storage #172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
sasial-dev
merged 5 commits into
red-blox:0.6.x
from
daimond113:feat/optimized-table-length
Apr 5, 2025
+45
−17
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0639dd6
Optimize table-like length storage
daimond113 9abe739
Only return unsigned integers
daimond113 745e792
Use unsigned numbers for signed variants
daimond113 66b3764
Don't store whole config
daimond113 61b221d
Fix overflow
daimond113 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,7 +33,7 @@ pub struct Config<'src> { | |
| pub disable_fire_all: bool, | ||
| } | ||
|
|
||
| impl Config<'_> { | ||
| impl<'src> Config<'src> { | ||
| pub fn server_reliable_count(&self) -> usize { | ||
| let reliable_count = self | ||
| .evdecls | ||
|
|
@@ -75,6 +75,17 @@ impl Config<'_> { | |
| pub fn client_reliable_ty(&self) -> NumTy { | ||
| NumTy::from_f64(0.0, self.client_reliable_count() as f64 - 1.0) | ||
| } | ||
|
|
||
| pub fn resolve_ty<'a>(&'a self, ty: &'a Ty<'src>) -> &'a Ty<'src> { | ||
| match ty { | ||
| Ty::Ref(name) => self | ||
| .tydecls | ||
| .iter() | ||
| .find(|decl| decl.name == *name) | ||
| .map_or(ty, |decl| &decl.ty), | ||
| _ => ty, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #[derive(Debug, Clone, Copy)] | ||
|
|
@@ -251,9 +262,9 @@ impl<'src> Ty<'src> { | |
| } | ||
| } | ||
|
|
||
| Self::Map(..) => (2, None), | ||
| Self::Map(..) => (self.variants_size().unwrap().size(), None), | ||
|
|
||
| Self::Set(..) => (2, None), | ||
| Self::Set(..) => (self.variants_size().unwrap().size(), None), | ||
|
|
||
| Self::Opt(ty) => { | ||
| let (_, ty_max) = ty.size(tydecls, recursed); | ||
|
|
@@ -313,6 +324,24 @@ impl<'src> Ty<'src> { | |
| Self::Unknown => (0, None), | ||
| } | ||
| } | ||
|
|
||
| pub fn variants_size(&self) -> Option<NumTy> { | ||
| match self { | ||
| Ty::Enum(Enum::Unit(variants)) => Some(NumTy::from_f64(0.0, (variants.len() - 1) as f64)), | ||
| Ty::Enum(Enum::Tagged { variants, .. }) => Some(NumTy::from_f64(0.0, (variants.len() - 1) as f64)), | ||
| Ty::Num(numty, ..) => match numty { | ||
| NumTy::F32 => None, | ||
| NumTy::F64 => None, | ||
| NumTy::U8 => Some(NumTy::U8), | ||
| NumTy::U16 => Some(NumTy::U16), | ||
| NumTy::U32 => None, | ||
| NumTy::I8 => Some(NumTy::U8), | ||
| NumTy::I16 => Some(NumTy::U16), | ||
| NumTy::I32 => None, | ||
| }, | ||
| _ => None, | ||
| } | ||
| } | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function is really weird. |
||
| } | ||
|
|
||
| #[derive(Debug, Clone)] | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.