Skip to content

Instantly share code, notes, and snippets.

View jdm's full-sized avatar

Josh Matthews jdm

View GitHub Profile
require 'rubygems'
require 'hpricot'
module HpricotTruncator
module NodeWithChildren
def truncate(max_length)
return self if inner_text.length <= max_length
truncated_node = self.dup
truncated_node.children = []
each_child do |node|
Jarlaxle-2:~ josh$ jruby hpricot-test.rb
RubyBasicObject.java:1058:in `getVariableList': java.lang.ClassCastException: [Lorg.jruby.runtime.builtin.IRubyObject; cannot be cast to org.jruby.runtime.builtin.IRubyObject
from RubyBasicObject.java:727:in `initCopy'
from RubyBasicObject.java:712:in `dup'
from RubyObject.java:734:in `dup'
from org/jruby/RubyObject$i_method_0_0$RUBYINVOKER$dup.gen:-1:in `call'
from CachingCallSite.java:258:in `cacheAndCall'
from CachingCallSite.java:77:in `call'
from hpricot-test.rb:8:in `method__2$RUBY$truncate'
from hpricot_minus_test#truncate:-1:in `call'
@jdm
jdm / debugperf.diff
Created January 29, 2012 23:55
Perf improvements for debuginfo
diff --git a/src/comp/middle/debuginfo.rs b/src/comp/middle/debuginfo.rs
index 4d81b68..0ab1a8e 100644
--- a/src/comp/middle/debuginfo.rs
+++ b/src/comp/middle/debuginfo.rs
@@ -101,7 +101,7 @@ type metadata<T> = {node: ValueRef, data: T};
type file_md = {path: str};
type compile_unit_md = {path: str};
-type subprogram_md = {path: str};
+type subprogram_md = {id: ast::node_id};
#define GL_GLEXT_PROTOTYPES
#include <GL/gl.h>
#include <GL/glext.h>
typedef void (*shaderfunc)(GLuint shader, GLsizei count, const char** str, const GLint* length);
int main(int argc, char **argv) {
shaderfunc f = glShaderSource;
return 0;
}
@jdm
jdm / gist:5680884
Last active December 17, 2015 22:19
diff --git a/src/components/servo-gfx/font.rs b/src/components/servo-gfx/font.rs
index 6405c0f..37a712d 100644
--- a/src/components/servo-gfx/font.rs
+++ b/src/components/servo-gfx/font.rs
@@ -204,6 +204,7 @@ A font instance. Layout can use this to calculate glyph metrics
and the renderer can use it to render text.
*/
pub struct Font {
+ priv context: *mut FontContext,
priv handle: FontHandle,
diff --git a/src/components/servo/layout/layout_task.rs b/src/components/servo/layout/layout_task.rs
index 27b9dd8..c83414e 100644
--- a/src/components/servo/layout/layout_task.rs
+++ b/src/components/servo/layout/layout_task.rs
@@ -87,6 +87,7 @@ pub struct BuildData {
window_size: Size2D<uint>,
script_join_chan: Chan<()>,
damage: Damage,
+ render: bool
}
diff --git a/src/components/servo-util/tree.rs b/src/components/servo-util/tree.rs
index 23b8ca8..09a4070 100644
--- a/src/components/servo-util/tree.rs
+++ b/src/components/servo-util/tree.rs
@@ -132,6 +132,7 @@ impl<NR:TreeNodeRef<N>,N:TreeNode<NR>> TreeUtils for NR {
}
}
+ #[inline(always)]
fn each_child(&self, callback: &fn(NR) -> bool) -> bool {
diff --git a/src/components/servo-gfx/platform/linux/font.rs b/src/components/servo-gfx/platform/linux/font.rs
index 1eddd68..b6e7bc9 100644
--- a/src/components/servo-gfx/platform/linux/font.rs
+++ b/src/components/servo-gfx/platform/linux/font.rs
@@ -25,6 +25,8 @@ use freetype::freetype::{FT_SizeRec, FT_UInt, FT_Size_Metrics};
use freetype::freetype::{ft_sfnt_os2};
use freetype::tt_os2::TT_OS2;
+use core::hashmap::HashMap;
+
diff --git a/src/components/servo-gfx/font_context.rs b/src/components/servo-gfx/font_context.rs
index 87c1b63..880c7d3 100644
--- a/src/components/servo-gfx/font_context.rs
+++ b/src/components/servo-gfx/font_context.rs
@@ -38,6 +38,7 @@ pub trait FontContextHandleMethods {
pub struct FontContext {
instance_cache: MonoCache<FontDescriptor, @mut Font>,
shaper_cache: MonoCache<FontDescriptor, @Shaper>,
+ group_cache: MonoCache<SpecifiedFontStyle, @FontGroup>,
font_list: Option<FontList>, // only needed by layout
diff --git a/src/components/gfx/font.rs b/src/components/gfx/font.rs
index 37a712d..da93a13 100644
--- a/src/components/gfx/font.rs
+++ b/src/components/gfx/font.rs
@@ -18,6 +18,8 @@ use azure::scaled_font::ScaledFont;
use azure::azure_hl::{BackendType, ColorPattern};
use geom::{Point2D, Rect, Size2D};
+use core::hashmap::HashMap;
+