mirror of
https://github.com/denoland/deno.git
synced 2024-11-26 16:09:27 -05:00
refactor(cli/inspector): use &str for post_message (#7851)
This changes the signature of InspectorSession.post_message to take a &str rather than a String avoiding the need call str.to_string at each call site.
This commit is contained in:
parent
7ab645f512
commit
cb3a3a1e95
3 changed files with 10 additions and 22 deletions
|
@ -20,20 +20,14 @@ impl CoverageCollector {
|
|||
}
|
||||
|
||||
pub async fn start_collecting(&mut self) -> Result<(), AnyError> {
|
||||
self
|
||||
.session
|
||||
.post_message("Debugger.enable".to_string(), None)
|
||||
.await?;
|
||||
self.session.post_message("Debugger.enable", None).await?;
|
||||
|
||||
self
|
||||
.session
|
||||
.post_message("Profiler.enable".to_string(), None)
|
||||
.await?;
|
||||
self.session.post_message("Profiler.enable", None).await?;
|
||||
|
||||
self
|
||||
.session
|
||||
.post_message(
|
||||
"Profiler.startPreciseCoverage".to_string(),
|
||||
"Profiler.startPreciseCoverage",
|
||||
Some(json!({"callCount": true, "detailed": true})),
|
||||
)
|
||||
.await?;
|
||||
|
@ -44,7 +38,7 @@ impl CoverageCollector {
|
|||
pub async fn collect(&mut self) -> Result<Vec<Coverage>, AnyError> {
|
||||
let result = self
|
||||
.session
|
||||
.post_message("Profiler.takePreciseCoverage".to_string(), None)
|
||||
.post_message("Profiler.takePreciseCoverage", None)
|
||||
.await?;
|
||||
|
||||
let take_coverage_result: TakePreciseCoverageResult =
|
||||
|
@ -55,7 +49,7 @@ impl CoverageCollector {
|
|||
let result = self
|
||||
.session
|
||||
.post_message(
|
||||
"Debugger.getScriptSource".to_string(),
|
||||
"Debugger.getScriptSource",
|
||||
Some(json!({
|
||||
"scriptId": script_coverage.script_id,
|
||||
})),
|
||||
|
@ -77,16 +71,10 @@ impl CoverageCollector {
|
|||
pub async fn stop_collecting(&mut self) -> Result<(), AnyError> {
|
||||
self
|
||||
.session
|
||||
.post_message("Profiler.stopPreciseCoverage".to_string(), None)
|
||||
.await?;
|
||||
self
|
||||
.session
|
||||
.post_message("Profiler.disable".to_string(), None)
|
||||
.await?;
|
||||
self
|
||||
.session
|
||||
.post_message("Debugger.disable".to_string(), None)
|
||||
.post_message("Profiler.stopPreciseCoverage", None)
|
||||
.await?;
|
||||
self.session.post_message("Profiler.disable", None).await?;
|
||||
self.session.post_message("Debugger.disable", None).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -901,7 +901,7 @@ impl InspectorSession {
|
|||
|
||||
pub async fn post_message(
|
||||
&mut self,
|
||||
method: String,
|
||||
method: &str,
|
||||
params: Option<serde_json::Value>,
|
||||
) -> Result<serde_json::Value, AnyError> {
|
||||
let id = self.next_message_id;
|
||||
|
|
|
@ -38,7 +38,7 @@ async fn post_message_and_poll(
|
|||
method: &str,
|
||||
params: Option<Value>,
|
||||
) -> Result<Value, AnyError> {
|
||||
let response = session.post_message(method.to_string(), params);
|
||||
let response = session.post_message(method, params);
|
||||
tokio::pin!(response);
|
||||
|
||||
loop {
|
||||
|
|
Loading…
Reference in a new issue