Skip to content

Instantly share code, notes, and snippets.

View shyouhei's full-sized avatar

卜部昌平 shyouhei

View GitHub Profile
From edb99670b714b12525f36d6f9b174a72a75026b3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?=
<shyouhei@ruby-lang.org>
Date: Wed, 23 Oct 2019 17:10:10 +0900
Subject: [PATCH] optimize CLASS_OF
---
include/ruby/ruby.h | 28 +++++++++++++++++++---------
1 file changed, 19 insertions(+), 9 deletions(-)
From 7b6bbba78cb2fcfb2a9def7d2c31aad64c03b5c5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?=
<shyouhei@ruby-lang.org>
Date: Wed, 24 Jul 2019 16:29:59 +0900
Subject: [PATCH] greetings.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: 卜部昌平 <shyouhei@ruby-lang.org>

ASUS ZenBook 3 ファーストインプレッション

前使ってたSony VAIO Pro 11が壊れた。

"Sony"は勘違いではなく、実際まだVAIOが分社化する前に買ったものだ。なのでかなりながらく使っていたと思う。すぐ壊れるという前評判と経験則をおおいに裏切って延長保証が切れるまでなんの問題もなく動き続けてくれた。買ってよかったと思う。

とはいうものの壊れてしまったので、別のものを買わなければいけないのだが、残念ながら今回はVAIOは選択肢に入らない。VAIO Pro 11に相当する後継製品がないからだ。なおS11はキーボードがNG。

色々と調べた限りでは国内で買える選択肢は少なそう。しょうがないので、ASUS ZenBook 3 UX390UAKを個人輸入でUS Amazonで買った。

From 366e7e37b5f54c5d359a32f4324b6b90a6c7d33a Mon Sep 17 00:00:00 2001
From: "Urabe, Shyouhei" <shyouhei@ruby-lang.org>
Date: Mon, 21 Jan 2019 19:04:17 +0900
Subject: [PATCH] send-pop optimisation part two: eliminate pop
Sending a method, then immediately throwing away its return value, is
one of the most frequent waste of time that ruby does. Now that
callee methods can skip pushing objects onto the stack, why not caller
sites to also avoid popping them.
@shyouhei
shyouhei / md2dom.rb
Created February 20, 2017 03:57
DOM of a Markdown document. Because Redcarpet is strongly HTML-centric we cannot pass non-String return values around. We instead have to retain all generated s-expressions and left markers of them in the return value. The DOM is constructed back from that info after we finished rendering.
#! /your/favourite/path/to/ruby
# -*- coding: utf-8 -*-
# -*- frozen_string_literal: true -*-
# -*- warn_indent: true -*-
require 'redcarpet'
class MD2DOM < Redcarpet::Render::Base
def preprocess str
@sexp = []
From dc34706366802534e8f24b4efc312942c31cca72 Mon Sep 17 00:00:00 2001
From: "Urabe, Shyouhei" <shyouhei@ruby-lang.org>
Date: Wed, 5 Sep 2018 14:15:08 +0900
Subject: [PATCH] print N-gram of instructions that run
This is different from N-gram of generated iseq. Rather it prints
the sequence that was actually executed.
Signed-off-by: Urabe, Shyouhei <shyouhei@ruby-lang.org>
---
diff --git a/lib/crypt_checkpass/argon2.rb b/lib/crypt_checkpass/argon2.rb
index 08f22dd..c42f374 100644
--- a/lib/crypt_checkpass/argon2.rb
+++ b/lib/crypt_checkpass/argon2.rb
@@ -191,7 +191,7 @@ class CryptCheckpass::Argon2 < CryptCheckpass
require 'argon2'
@dll = Module.new do
extend FFI::Library
- lib = FFI::Compiler::Loader.find 'argon2_wrap'
+ lib = ::Argon2::Ext.ffi_libraries.first.name
diff --git a/string.c b/string.c
index 435954d313..8a264acef4 100644
--- a/string.c
+++ b/string.c
@@ -9220,11 +9220,9 @@ rb_str_crypt(VALUE str, VALUE salt)
{
#ifdef HAVE_CRYPT_R
VALUE databuf;
- struct crypt_data *data;
-# define CRYPT_END() ALLOCV_END(databuf)
Index: trunk/compile.c
===================================================================
--- trunk/compile.c (revision 63362)
+++ trunk/compile.c (working copy)
@@ -8929,7 +8929,7 @@
dump_body.ci_entries = ibf_dump_ci_entries(dump, iseq);
dump_body.cc_entries = NULL;
dump_body.variable.coverage = Qnil;
- dump_body.variable.original_iseq = Qnil;
+ dump_body.variable.original_iseq = NULL;
--- before.txt 2018-01-26 13:38:32.000000000 +0900
+++ after.txt 2018-01-26 13:38:57.000000000 +0900
@@ -719,15 +719,15 @@ miniruby[0x1002259d7] <+3223>: movq %r
miniruby[0x1002259da] <+3226>: movq %r15, %rsi
miniruby[0x1002259dd] <+3229>: vzeroupper
miniruby[0x1002259e0] <+3232>: callq 0x100218b00 ; vm_trace at vm_insnhelper.c:3805
-miniruby[0x1002259e5] <+3237>: leaq 0x8(%r14), %rax
-miniruby[0x1002259e9] <+3241>: movq %r14, %rcx
-miniruby[0x1002259ec] <+3244>: movq %rax, (%r15)
-miniruby[0x1002259ef] <+3247>: movq %rax, %r14