← Back to team overview

zeitgeist team mailing list archive

[Merge] lp:~mhr3/zeitgeist/string-chunks into lp:zeitgeist

 

Michal Hruby has proposed merging lp:~mhr3/zeitgeist/string-chunks into lp:zeitgeist.

Requested reviews:
  Siegfried Gevatter (rainct)

For more details, see:
https://code.launchpad.net/~mhr3/zeitgeist/string-chunks/+merge/85259

As discussed on IRC...
-- 
https://code.launchpad.net/~mhr3/zeitgeist/string-chunks/+merge/85259
Your team Zeitgeist Framework Team is subscribed to branch lp:zeitgeist.
=== modified file 'src/datamodel.vala'
--- src/datamodel.vala	2011-10-17 07:46:27 +0000
+++ src/datamodel.vala	2011-12-11 19:47:28 +0000
@@ -285,16 +285,40 @@
 
     public class Event : Object
     {
+        private static StringChunk url_store;
+
         public uint32    id { get; set; }
         public int64     timestamp { get; set; }
-        public string    interpretation { get; set; }
-        public string    manifestation { get; set; }
-        public string    actor { get; set; }
         public string    origin { get; set; }
 
+        public string actor
+        {
+            get { return _actor; }
+            set { _actor = url_store.insert_const (value); }
+        }
+        public string interpretation
+        {
+            get { return _interpretation; }
+            set { _interpretation = url_store.insert_const (value); }
+        }
+        public string manifestation
+        {
+            get { return _manifestation; }
+            set { _manifestation = url_store.insert_const (value); }
+        }
+
+        private unowned string _actor;
+        private unowned string _interpretation;
+        private unowned string _manifestation;
+
         public GenericArray<Subject> subjects { get; set; }
         public ByteArray? payload { get; set; }
 
+        static construct
+        {
+            url_store = new StringChunk (4096);
+        }
+
         construct
         {
             subjects = new GenericArray<Subject> ();
@@ -514,16 +538,41 @@
 
     public class Subject : Object
     {
+        private static StringChunk url_store;
 
         public string uri { get; set; }
-        public string interpretation { get; set; }
-        public string manifestation { get; set; }
-        public string mimetype { get; set; }
         public string origin { get; set; }
         public string text { get; set; }
         public string storage { get; set; }
+        // FIXME: current_uri is often the same as uri, we don't need to waste
+        // memory for it
         public string current_uri { get; set; }
 
+        public string mimetype
+        {
+            get { return _mimetype; }
+            set { _mimetype = url_store.insert_const (value); }
+        }
+        public string interpretation
+        {
+            get { return _interpretation; }
+            set { _interpretation = url_store.insert_const (value); }
+        }
+        public string manifestation
+        {
+            get { return _manifestation; }
+            set { _manifestation = url_store.insert_const (value); }
+        }
+
+        private unowned string _mimetype;
+        private unowned string _interpretation;
+        private unowned string _manifestation;
+
+        static construct
+        {
+            url_store = new StringChunk (4096);
+        }
+
         public Subject.from_variant (Variant subject_variant)
         {
             VariantIter iter = subject_variant.iterator();


Follow ups