-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf!: move to
threadpool
, fix excess memory usage
- Loading branch information
Showing
3 changed files
with
20 additions
and
87 deletions.
There are no files selected for viewing
This file contains 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 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 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 |
---|---|---|
@@ -1,54 +0,0 @@ | ||
use neorg_dirman::c_functions::FileList; | ||
use std::ffi::CStr; | ||
use std::mem::ManuallyDrop; | ||
|
||
use crate::breeze; | ||
use tree_sitter::ffi::TSTree; | ||
|
||
pub unsafe extern "C" fn parse_files(files: *const FileList) -> *const TSTree { | ||
let vec = unsafe { std::slice::from_raw_parts((*files).data, (*files).length) }.to_vec(); | ||
let paths = vec | ||
.into_iter() | ||
.map(|str| CStr::from_ptr(str).to_string_lossy().into_owned().into()) | ||
.collect(); | ||
|
||
let tree_vec = ManuallyDrop::new( | ||
breeze::parse_files(paths) | ||
.expect("Give me better error messages!") | ||
.into_iter() | ||
.map(|tree| *tree.into_raw()) | ||
.collect::<Vec<_>>(), | ||
); | ||
|
||
tree_vec.as_ptr() | ||
} | ||
|
||
#[cfg(test)] | ||
mod test { | ||
use super::*; | ||
use neorg_dirman::c_functions::*; | ||
use neorg_dirman::workspace::Workspace; | ||
|
||
#[test] | ||
fn test_parse_files() { | ||
unsafe { | ||
let workspace = Workspace { | ||
name: "test".into(), | ||
path: "test/example_workspace".into(), | ||
}; | ||
|
||
let files = workspace_files(&workspace); | ||
|
||
let tree = parse_files(files); | ||
assert!(!tree.is_null()); | ||
|
||
destroy_files(files); | ||
} | ||
} | ||
} | ||
|
||
// pub extern "C" fn parse_workspace(workspace: *mut Workspace) { | ||
// let vec = unsafe { std::slice::from_raw_parts((*files).data, (*files).length) }.to_vec(); | ||
// | ||
// let tree_vec = breeze::parse_files(); | ||
// } | ||