From 2e98c3d0644fc0c265844908f43b7e4526dd819c Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Thu, 23 Jun 2022 09:10:09 +0200 Subject: Grammar and spell check. --- doc/ext_ffi.html | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'doc/ext_ffi.html') diff --git a/doc/ext_ffi.html b/doc/ext_ffi.html index 7a87ca65..04b78d98 100644 --- a/doc/ext_ffi.html +++ b/doc/ext_ffi.html @@ -153,7 +153,7 @@ call the binding function. Phew!

Motivating Example: Using C Data Structures

The FFI library allows you to create and access C data -structures. Of course the main use for this is for interfacing with +structures. Of course, the main use for this is for interfacing with C functions. But they can be used stand-alone, too.

@@ -165,7 +165,7 @@ implemented with a big table holding lots of tiny tables. This imposes both a substantial memory overhead as well as a performance overhead.

-Here's a sketch of a library that operates on color images plus a +Here's a sketch of a library that operates on color images, plus a simple benchmark. First, the plain Lua version:

@@ -180,7 +180,7 @@ local function image_ramp_green(n)
   return img
 end
 
-local function image_to_grey(img, n)
+local function image_to_gray(img, n)
   for i=1,n do
     local y = floor(0.3*img[i].red + 0.59*img[i].green + 0.11*img[i].blue)
     img[i].red = y; img[i].green = y; img[i].blue = y
@@ -190,14 +190,14 @@ end
 local N = 400*400
 local img = image_ramp_green(N)
 for i=1,1000 do
-  image_to_grey(img, N)
+  image_to_gray(img, N)
 end
 

This creates a table with 160.000 pixels, each of which is a table -holding four number values in the range of 0-255. First an image with +holding four number values in the range of 0-255. First, an image with a green ramp is created (1D for simplicity), then the image is -converted to greyscale 1000 times. Yes, that's silly, but I was in +converted to grayscale 1000 times. Yes, that's silly, but I was in need of a simple example ...

@@ -304,7 +304,7 @@ be more compact and faster. This is certainly true (by a factor of ~1.7x). Switching to a struct-of-arrays would help, too.

-However the resulting code would be less idiomatic and rather +However, the resulting code would be less idiomatic and rather error-prone. And it still doesn't get even close to the performance of the FFI version of the code. Also, high-level data structures cannot be easily passed to other C functions, especially I/O functions, -- cgit v1.2.3-55-g6feb