Use compact_rc (#139)

There is not much use for weak_counts in Rc for us.

Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
Anand Krishnamoorthi
2024-02-09 23:22:09 -08:00
committed by GitHub
parent 5044d54d18
commit a381c38a90
7 changed files with 10 additions and 10 deletions
+1 -2
View File
@@ -5,12 +5,11 @@ use crate::ast::{Expr, Ref};
use crate::builtins;
use crate::builtins::utils::{ensure_args_count, ensure_array, ensure_numeric};
use crate::lexer::Span;
use crate::value::Value;
use crate::value::{Rc, Value};
use std::collections::HashMap;
use anyhow::Result;
use std::rc::Rc;
pub fn register(m: &mut HashMap<&'static str, builtins::BuiltinFcn>) {
m.insert("array.concat", (concat, 2));
+1 -2
View File
@@ -5,11 +5,10 @@ use crate::ast::{Expr, Ref};
use crate::builtins;
use crate::builtins::utils::{ensure_args_count, ensure_array, ensure_object};
use crate::lexer::Span;
use crate::value::Value;
use crate::value::{Rc, Value};
use std::collections::{BTreeMap, BTreeSet, HashMap};
use std::iter::Iterator;
use std::rc::Rc;
use anyhow::{bail, Result};
+3 -1
View File
@@ -157,7 +157,9 @@ fn to_string(v: &Value, unescape: bool) -> String {
match v {
Value::Null => "null".to_owned(),
Value::Bool(b) => b.to_string(),
Value::String(s) if unescape => serde_json::to_string(&s).unwrap_or(s.as_ref().to_string()),
Value::String(s) if unescape => {
serde_json::to_string(s.as_ref()).unwrap_or(s.as_ref().to_string())
}
Value::String(s) => s.as_ref().to_string(),
Value::Number(n) => n.format_decimal(),
Value::Array(a) => {
+1 -2
View File
@@ -4,10 +4,9 @@
use crate::ast::{Expr, Ref};
use crate::lexer::Span;
use crate::number::Number;
use crate::value::Value;
use crate::value::{Rc, Value};
use std::collections::{BTreeMap, BTreeSet};
use std::rc::Rc;
use anyhow::{bail, Result};
+1 -2
View File
@@ -16,7 +16,6 @@ use log::info;
use std::collections::btree_map::Entry as BTreeMapEntry;
use std::collections::{hash_map::Entry, BTreeMap, BTreeSet, HashMap};
use std::ops::Bound::*;
use std::rc::Rc;
use std::str::FromStr;
type Scope = BTreeMap<SourceStr, Value>;
@@ -61,7 +60,7 @@ pub struct Interpreter {
active_rules: Vec<Ref<Rule>>,
builtins_cache: BTreeMap<(&'static str, Vec<Value>), Value>,
no_rules_lookup: bool,
traces: Option<Vec<std::rc::Rc<str>>>,
traces: Option<Vec<Rc<str>>>,
allow_deprecated: bool,
strict_builtin_errors: bool,
imports: BTreeMap<String, Ref<Expr>>,
+2 -1
View File
@@ -8,7 +8,6 @@ use std::collections::{BTreeMap, BTreeSet};
use std::convert::AsRef;
use std::ops;
use std::path::Path;
use std::rc::Rc;
use std::str::FromStr;
use anyhow::{anyhow, bail, Result};
@@ -16,6 +15,8 @@ use serde::de::{self, Deserializer, MapAccess, SeqAccess, Visitor};
use serde::ser::{SerializeMap, Serializer};
use serde::{Deserialize, Serialize};
pub type Rc<T> = compact_rc::Rc16<T>;
/// A value in a Rego document.
///
/// Value is similar to a [`serde_json::value::Value`], but has the following additional