Add _unguarded to RawLua::app_data_ref (for internal use only)

This commit is contained in:
Alex Orlenko
2024-10-07 13:00:57 +01:00
parent 03a4068d55
commit 640cb2c182
2 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -481,7 +481,7 @@ impl<'a> Chunk<'a> {
if let Ok(ref source) = self.source {
if self.detect_mode() == ChunkMode::Text {
let lua = self.lua.lock();
if let Some(cache) = lua.app_data_ref::<ChunksCache>() {
if let Some(cache) = lua.app_data_ref_unguarded::<ChunksCache>() {
if let Some(data) = cache.0.get(source.as_ref()) {
self.source = Ok(Cow::Owned(data.clone()));
self.mode = Some(ChunkMode::Binary);
@@ -498,7 +498,7 @@ impl<'a> Chunk<'a> {
if let Ok(ref binary_source) = self.source {
if self.detect_mode() == ChunkMode::Binary {
let lua = self.lua.lock();
if let Some(mut cache) = lua.app_data_mut::<ChunksCache>() {
if let Some(mut cache) = lua.app_data_mut_unguarded::<ChunksCache>() {
cache.0.insert(text_source, binary_source.as_ref().to_vec());
} else {
let mut cache = ChunksCache(HashMap::new());
+2 -2
View File
@@ -285,7 +285,7 @@ impl RawLua {
/// See [`Lua::app_data_ref`]
#[track_caller]
#[inline]
pub(crate) fn app_data_ref<T: 'static>(&self) -> Option<AppDataRef<T>> {
pub(crate) fn app_data_ref_unguarded<T: 'static>(&self) -> Option<AppDataRef<T>> {
let extra = unsafe { &*self.extra.get() };
extra.app_data.borrow(None)
}
@@ -293,7 +293,7 @@ impl RawLua {
/// See [`Lua::app_data_mut`]
#[track_caller]
#[inline]
pub(crate) fn app_data_mut<T: 'static>(&self) -> Option<AppDataRefMut<T>> {
pub(crate) fn app_data_mut_unguarded<T: 'static>(&self) -> Option<AppDataRefMut<T>> {
let extra = unsafe { &*self.extra.get() };
extra.app_data.borrow_mut(None)
}