Преглед изворни кода

refactor: dont pass in entire context

Sam Jaffe пре 1 година
родитељ
комит
9257625910
2 измењених фајлова са 5 додато и 5 уклоњено
  1. 4 4
      include/jvalidate/detail/reference_manager.h
  2. 1 1
      include/jvalidate/schema.h

+ 4 - 4
include/jvalidate/detail/reference_manager.h

@@ -26,12 +26,12 @@ public:
 private:
   ConstraintFactory<A> const & constraints_;
   DocumentCache<A> & external_;
-  ReferenceCache references_;
 
+  ReferenceCache references_;
   std::map<RootReference, A> roots_;
+  std::map<URI, std::map<Anchor, Reference>> dynamic_anchors_;
 
   DynamicReferenceContext active_dynamic_anchors_;
-  std::map<URI, std::map<Anchor, Reference>> dynamic_anchors_;
 
 public:
   ReferenceManager(DocumentCache<A> & external, A const & root, schema::Version version,
@@ -46,7 +46,7 @@ public:
     return active_dynamic_anchors_.scope(uri, dynamic_anchors_[uri]);
   }
 
-  std::optional<A> load(Reference const & ref, ParserContext<A> const & context) {
+  std::optional<A> load(Reference const & ref, schema::Version version) {
     if (auto it = roots_.find(ref.root()); it != roots_.end()) {
       return ref.pointer().walk(it->second);
     }
@@ -58,7 +58,7 @@ public:
 
     // TODO(samjaffe): Change Versions if needed...
     references_.emplace(ref.uri());
-    prime(*external, ref, context.version, constraints_.keywords(context.version));
+    prime(*external, ref, version, constraints_.keywords(version));
 
     // May have a sub-id that we map to
     if (auto it = roots_.find(ref.root()); it != roots_.end()) {

+ 1 - 1
include/jvalidate/schema.h

@@ -193,7 +193,7 @@ private:
       return *cached;
     }
 
-    if (std::optional root = context.ref.load(lexical, context)) {
+    if (std::optional root = context.ref.load(lexical, context.version)) {
       return fetch_schema(context.rebind(*root, lexical, dynamic));
     }